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

ASP/Javascript postback question

Status
Not open for further replies.

mellenburg

Programmer
Aug 27, 2001
77
0
0
US
I have a form with three drop down list items. The values for the first item can be a 1, 2, or 3. Once the user selects one of the three values, the second drop down list is populated with the remaining values via a javascript program that is called by the OnChange command.

For example, the user chooses 1 for the first box, the second box is then populated with the values 2 and 3. If the user selects 2 for the second box, the third box only has the value 3.

The page works fine when the user submits the value, but if he or she wishes to change the value, I don't know how to postback the values for the second and third box.

For the first box, I've added ASP logic for each value (1,2,3) that says 'if request("box1") = 1 then response.write "selected"'. That approach works.

For the second and third boxes, I don't have the values in the ASP code because they are controlled by the Javascript program.

What kind of approach/es will help me post back the user's original value for box 2 and 3? Will it need to be done with ASP code or with Javascript code?

Matt
 
You need to give each one it's own ID and Name in the INPUT line so that when your OnClick event takes place you can have your function do what it needs to do for each one. If your ID and Name were a, b and c then your function would be something like this assuming your OnClick event is set to call my example Check() function below.

Code:
<SCRIPT LANGUAGE=javascript TYPE="text/javascript">
<!--
	function Check()
	{
		if(document.a.value == 0)
		{
			document.a.focus();
			return false;
		}
        if(document.b.value == 0)
		{
			document.b.focus();
			return false;
		}
        if(document.c.value == 0)
		{
			document.b.focus();
			return false;
		}
	}
//-->
</SCRIPT>

This is just an example. I hope it kind of explains what is trying to be accomplished.

JP
 
By the way, you need to post in the javascript or ASP forum next time. This forum is for vbscript only.

JP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top