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

Using Javascript variable in asp

Status
Not open for further replies.

PeteCan

Programmer
Jan 15, 2002
60
GB
I have an asp page which has a dropdown box in it. Using the onchange event I want to decide whether to do something or not.
The event calls this javascript

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function HandleChange() {
var list = document.form1.seltest;
var listValue= list.options[list.selectedIndex].value;
}
//-->
</SCRIPT>

However how do I get the listvalue value and use it within the vbscript code to make the decision
 

When you say VBScript, I'm assuming that you mean server-side VBScript. If so, then you cannot test for the value of the selected option without doing a form submission to another [ASP] page (as the server-side code will clearly have already run by the time the page is delivered).

Hope this helps,
Dan
 
rather than using vbscript can i do it just using javascript then?
What i want to is have a drop down box containing 4 entries. If they select the 'onhold' option then I want a text box to appear below it for them to enter a date, if they select any other option they don't get the text box and then just press submit to update the database.

I've never used Javascript, although have just order a book!, so don't know it's full capabilities.

thanks
 

Try this for size:

Code:
<html>
<head>
	<script type="text/javascript">
	<!--
		function selectChanged(value) {
			if (value=='onhold') {
				document.forms['myForm'].myDateBox.style.display = 'block';
			} else {
				document.forms['myForm'].myDateBox.style.display = 'none';
			}
		}
	//-->
	</script>
</head>
<body>
	<form name="myForm">
		<select name="mySelect" onchange="selectChanged(this.value);">
			<option value="">Please select...</option>
			<option value="onhold">On Hold</option>
			<option value="notonhold">Not On Hold</option>
		</select>
		<br />
		<input type="text" name="myDateBox" value="Enter date here..." style="display:none;">
		<br />
		<input type="submit" value="Submit!">
	</form>
</body>
</html>

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top