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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax prob- retrieve & submit value from function

Status
Not open for further replies.

JonathanG6SWJ

Programmer
Jan 18, 2005
39
GB
Hi Guys.
I've played with the syntax below so much I've forgotten what I've tried and what I haven't. So I thank you in advance for keeping me sane. I am trying to retrieve the index value for the option box.

Here's the function
Code:
<script type="text/javascript">
function getIndex()
{
var x=document.getElementById("mySelect")
}
</script>
Here's an example of my option box
Code:
<select name="J" id="mySelect" >
	<option value="a">a</option>
	<option value="b">b</option>
	<option value="c" selected>c</option>
	</select>


Here's my submit code
Code:
<input type="hidden" name="Result" value="<%= getIndex()% >">

Basically I can't get the value="<%= getIndex()%>"> bit of code to work

Many thanks in advance
Jonathan
 
It looks like the getIndex() is not actually returning anything. What if you write it like this:

Code:
function getIndex()
{
  return(document.getElementById("mySelect"));
}


Also, unless you are using server-side javascript then this is not going to work because a client side function doesn't run while the ASP is processing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top