faqts : Computers : Programming : Languages : JavaScript : Forms : SELECT

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

75 of 87 people (86%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do you use a selected value as input to another function?

Aug 28th, 2000 10:09
Martin Honnen, Jim Baird,


You get the selected value with
  var select = document.formName.selectName;
  var value = select.options[select.selectedIndex].value;
Then you pass it into a function 
  functionName(value);
You can do that in the event handler onchange
  <SELECT NAME="selectnName"
          ONCHANGE="var value = this.options[this.selectedIndex].value;
                    functionName(value);"
  >