Page 1 of 1
Onkeyup Javascript from RPG
Posted: Fri Feb 01, 2019 10:24 am
by livio.daneluzzi
Hi to all...
I tried to looking for some answers, but without success, and I decided to aks here:
is it possibile to change the Javascript in onkeyup/onchange/onclick events of a textbox with a Javascript or PUI. command?
I've the commands I need in Javascript, to put in these events, in some variables on the screen (labels).
Thanks
Re: Onkeyup Javascript from RPG
Posted: Fri Feb 01, 2019 11:30 am
by Scott Klement
Sorry, I don't understand the question. Can you give me an example?
Re: Onkeyup Javascript from RPG
Posted: Fri Feb 01, 2019 3:21 pm
by livio.daneluzzi
Sorry Scott, I hope this will explain better: ;-)
I need to change the ONKEYUP, or ONCLICK, or ONCHANGE event attribute, of a TEXTBOX, with a Javascript command.
I saw there's way to change the attributes of a TEXTBOX in a display file, for example with the command:
setDOMAttribute("TEXTBOX1", "value", "abcdefgh");
and if I use "value" it works perfect, but I need to change, for example, "onclick" attribute, and I thought to modify the command like this one:
setDOMAttribute("TextBox1", "onclick", "some Javascript code");
but it doesn't work. It doesn't change the "onclick" attribute.
Is there a way to do it? Am I using the right command, or is there another one for to do this thing?
Thanks a lot
Re: Onkeyup Javascript from RPG
Posted: Fri Feb 01, 2019 5:11 pm
by Scott Klement
I'd never heard of setDOMAttribute() before your message. I looked, and it appears to be part of our software, but I've never heard of it before and never saw anyone use it.
If you want to add your own event handler to Profound UI at runtime, you would use the addEvent() API documented here:
http://www.profoundlogic.com/docs/pages ... Id=3276841
To remove that event handler (prior to adding a different one) you would use the removeEvent() API:
http://www.profoundlogic.com/docs/pages ... Id=3276843
Please note that if you're adding/removing events like this you are working at the DOM level, so you must only use this with browser events, not anything that's specific to Profound UI. In other words, you are working directly at the HTML level, NOT at the Profound widget level.
It is very unusual for a customer to do this, and I find it extremely strange that you would do that. I strongly suspect that you are asking the wrong question! Rather than changing the actual code while the display is running, it'd make much more sense to use stuff like if statements, etc, so that you run different code under different circumstances.
Re: Onkeyup Javascript from RPG
Posted: Mon Feb 04, 2019 4:38 am
by livio.daneluzzi
Thanks a lot Scott, for the answer.
I think that to change dinamically the Javascript while display running extends the possibility of manage it without limits.
It's only an idea and I think to try it... if all will works like I think, surely I can share the idea here in the forum. I don't know if, in the future, it will have an application somewhere.