on 05-19-2005 6:00 PM
Hi!
Does anyone know the correct JavaScript syntax to retrieve the Key and Value of the selected item from an HTMLB DropdownListBox?
I am doing something like the following, but I am missing the correct syntax for a few items:
var funcName = myFormID + "_getHtmlbElementId";
func = window(funcName);
var selected = eval(func("dropdown_id"));
var inf1 = eval(func("input_filed1"));
var inf2 = eval(func("input_field2"));
if (selected) {
var key = selected.getValue();
inf2.setValue(key);
//I don't know how to get the corresponding text for the selected key
var text = selected.getTextForValue();
inf1.setValue(text);
}
Thank you!
Thanks Prakash!
Now that I am getting past those errors, I can see the output. Back to retrieving the key and value of the dropdownListBox items...
selected.getValue() gives me the key of the selected item.
select.getIndex() gives me the position of the selected item (i.e. 1, 2, etc).
Do you know how I can retrieve the actual <i>value</i> of the selected item?
If the item is defined as:
<hbj:listBoxItem id="item1" value="This is Item 1" />
I can get "item1" from .getValue(), but how do I retrieve "This is Item 1?"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That worked! Thanks for all your help, Prakash!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great! That worked. Now I get a 'Member Not Found' error at:
func = window(funcName);
Any ideas?
Thank you for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the hints!
I am getting a 'myFormID is undefined' JavaScript error when the function is run. How, exactly, do I call the formID in the funcName line?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexa,
The following syntax will get you the index and the value.
var index = selected.getIndex();
var value = selected.getValue();
make sure you are setting the value<b> jsObjectNeeded = true</b> for your dropdown list box.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.