|
-
Oct 20th, 2002, 12:09 AM
#1
Thread Starter
Lively Member
How to pass select option value to a function
I am using Select and JavaScript. When a user selects any value, I like to pass that value to JavaScript function but I cannot pass it. I can pass any value for input value. Is there any way that I can pass any value to a function, when user selects any option? Please see my sample select and function.
<select name=sTermPref <%=Trim(RSCHECK("sTermPref"))%> size="1" onChange = "getInfo()">
<option selected> <%if RSCHECK("sTermPref") <> "" then response.write RSCHECK("sTermPref") %>
</option>
<option>Variable</option>
<option>6 Month Closed</option>
<option>6 Month Convertible</option>
<option>6 Month Open</option>
<option>1 Year Closed</option>
<option>1 Year Convertible</option>
<option>1 Year Open</option>
<option>2 Year Closed</option>
<option>3 Year Closed</option>
<option>4 Year Closed</option>
<option>5 Year Closed</option>
<option>7 Year Closed</option>
<option>10 Year Closed</option>
</select>
<SCRIPT language="JavaScript">
function getInfo() {
alert document.forms[0].sTermPref.value ;
}
</SCRIPT>
-
Oct 20th, 2002, 06:46 AM
#2
Frenzied Member
Something like this?
Code:
<script type="text/javascript"><!--
function showOption(option) {
alert(option);
}
//--></script>
<select onchange="showOption(this.options[this.options.selectedIndex].value);">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
</select>
-
Oct 20th, 2002, 08:24 AM
#3
Thread Starter
Lively Member
Hi Rick
Thank you very much. You save me a lot of time
Naci
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|