• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing code

 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following:


Origially, this was used to grab the value of a radio button, but I needed to change this to a listbox. Can I use the same code for a <select> if I name the <select> "callerName" and I keep the "value=" attributes the same for the listbox as I did for the radio buttons?

[ December 30, 2005: Message edited by: K Robert ]
[ December 30, 2005: Message edited by: K Robert ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
var sel = forms['CONFIG'].elements['CallerName'];
var strValue = sel.options[sel.selectedIndex].value;
var strText = sel.options[sel.selectedIndex].text;

Eric
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great thanks! But, how do I select the right value to display in the listbox base on the variable name?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
loop through the options, read the value, then select when found.



Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic