Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select option to variable

Status
Not open for further replies.

playerx

Technical User
Joined
Feb 23, 2006
Messages
10
Location
US
I have this selection option pull down. Once I select an option can I put that selection in a variable.

If so can does someone have an example.

<select name="dep" id="dep">
<option></option>
<option>test1</option>
<option>test2</option> <option>test3</option
</select>
 
This should be in the JS Forum...
Code:
<select onChange="myVar = this.options[this.selectedInded].value">

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Sorry for the typo...

Code:
<select onChange="myVar = this.options[this.[blue]selectedIndex[/blue]].value">

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
<td width="228"><select onChange="myVar = this.options[this.selectedIndex].value" name="select2">
<option value="value"></option>

Ok I set this up.

Now what would be next: do I need to set up a function?

The goal here is once I get the value into a variable I want to pass that varibale to another page.

thanks in advance
 
Code:
<select onChange="document.location='nextPage.asp?passedVal=" + this.options[this.selectedIndex].value + "'">

You could also say
Code:
<form name="myForm" method=post action="nextPage.asp">
<select name="passedVal" onChange="document.myForm.submit()">

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top