Page 1 of 1
Retrieving current selection value from a drop down box
Posted: Tue Apr 17, 2012 4:46 pm
by Stuart
Hello, I need to retrieve the selected value from a dropdown box, via Javascript.
I am coding the "onchange" event for the dropdown widget.
I have tried:
get("selectBox"),
var combo = document.getElementById("selectBox");
var strUser = combo[combo.selectedIndex].text;
None of these work.
Thanks for the help!
Re: Retrieving current selection value from a drop down box
Posted: Tue Apr 17, 2012 5:01 pm
by rmullis
Try this:
var selectText = getObj("SelectBoxID");
Re: Retrieving current selection value from a drop down box
Posted: Tue Apr 17, 2012 5:46 pm
by Stuart
Thanks for the tip!
I need to elaborate on the problem more:
The dropdown box is attached to a table (subfile)
There are 2 options, and one of those options needs to run a pc Command
The iSeries (RPG) program runs a host command to create a PDF file
The pdf file then needs to be passed as a parameter to the pc Command.
Since the pdf is being generated thru a host command, based on user selection,
and then a PC command needs to run to process the file, how can I achieve all this
with the onchange event of the drop down box? By the way, the pdf file name is variable, so I need to pass control to the RPG program to create the file, and then run a javascript (runPCCommand) that will process the command string that is created in the RPG program.
Can all this be done with one button click? I am beginning to think that I may need 2 events, one to create the PDF, and the other event to send the file.
(I decided to post this as a seperate topic)
Re: Retrieving current selection value from a drop down box
Posted: Tue Apr 17, 2012 6:25 pm
by Stuart
var selected = getObj("selectBox");
alert(selected);
if (selected == "DISPLAY") pui.click("Event");
if (selected == "SEND TO IR") processCommands(get("Command"));
when using the getObj command, passing the id of the dropdown box, the popup
displays "null" (this is coded on an "onchange" event)