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!

I have a form with 2 drop down list

Status
Not open for further replies.

Joules

MIS
Apr 25, 2001
28
US
I have a form with 2 drop down lists that the second is dependent on the first selection. I am using javascript to populate the list, but...

* The user will continue from the form to a confirmation page.
* If they need to make a change, they browse back to make that change.
* When they browse back, the values of the dependent lists are gone and my check to ensure that all fields have values isn't working on the dependent drop down list.

This has become a problem. I know that there is a way to do this using ASP, I believe it uses 2 forms on the one page but I am not sure how to do this.

Any Suggestions/Examples ?

Thanks :->
 
When the user needs to go back to the original form, instead of making it an ordinary hyperlink, make it a submit button for a form with a bunch of hidden values.

populate the hidden fields with values from the 1st form.

ex: (confirmation.asp)
<form action=&quot;1stform.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;fullname&quot; value=&quot;from the first form&quot;>
<input type=&quot;submit&quot; value=&quot;go back&quot;>
</form>


on the 1stform.asp page, for each form value, try grabbing the value from the Request.Form(&quot;name&quot;) collection and putting it into the box.

ex:(1stform.asp)
<form action=&quot;confirmation.asp&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;fullname&quot; value=&quot;<%=Request.Form(&quot;fullname&quot;)%>&quot;>
...
</form>

and so on.
using my examples, when the user hits the 'go back' button on confirmation.asp, the user goes back to 1stform.asp. In 1stform.asp, the value of the testbox fullname will be 'from the first form' (again using my above example).
If the Request.Form(&quot;fullname&quot;) is empty, then there will be no value inside the box (roughly equivalent to value=&quot;&quot;).

hope this helps you out.
leo
 
Leo,

I tried your suggestion and it populated the regular input boxes, but not the drop down menus or the textbox that is also part of the form.

Thanks,
Joules
 
I'm not 100% sure about this, but wouldn't you have to call the onchange() function of your drop-down list after you assign it a value? I don't think that the onchange() event will fire when you assign it a value. If the variable that you're pulling isn't null, assign your combo-box the value and then call the onchange() function with that value. I hope that'll help. Good luck

Doug
 
Joules
I tried to make dependant list dropdowns without success. I have a MS Access DB with, amongst others, a table called tbldepts and a query called qryUser. I would like to be able to have a user choose a dept in the first dropdown and the people related to that dept populate the second. The query gets its data from the users table but it concatenates the names (surname, forname). When the user chooses their name they can press submit to carry on. Since you have this working any help would be gratefully received.

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top