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

Dependent dynamic dropdown lists (Server side) 1

Status
Not open for further replies.

credo

Programmer
Jul 26, 2001
50
GB
Hello,
I'm trying to create two dependent Dynamic dropdown boxes in a form. The parent dropdown (Countries) will filter the child dropdown (Resorts).Countries data labels and values are fixed (ie.not dynamic).
I've spent some time struggling with MM's solution of doing this through arrays on the Client Side. I know several people have got this working ok, but my result set for resorts is quite big and may slow my page down anyway so I'm thinking of going to the server.

Can anyone point me towards an example tutorial/script that will help me with building the following process. I can only seem a reference to MM's solution?

Process will be:
1) User selects a Country from first dropdown
2) Go off to server, use the Country to filter Resorts
3) Filtered resorts appear in Resort dropdown
4) User selects resort

Do I need a Javascript on change event for when a user selects a country from the country dropdown ? ie. how do I force the form to go and lookup resorts per country when a user selects a different country ?

Any help appreciated.
 
This is how I would do it with a trip to the server:

1) Use onChange on the Country Dropdown to call a client side JavaScript function which sets the value of a hidden tag name=&quot;action&quot; to something like &quot;LoadResorts&quot;(<input type=&quot;hidden&quot; name=&quot;action&quot;>) Code:
<select name=&quot;country&quot; onChange=&quot;SubmitThisForm('LoadResorts');&quot;>
<option value=&quot;US&quot;>US</option>
...
</select>

<SCRIPT language='JavaScript'>
function SubmitThisForm (action){

document.forms[0].element['action'].value = action;
document.forms[0].submit();

}
</SCRIPT>


2) on the post page (target of the form action) on the server use Request and a Select Case statement to get the value of the action tag.

3) if the action = &quot;LoadResorts&quot; get the appropriate record set and reload the page.

4) use the onClick property of the button to call the same JavaScript function this time setting the action tag = &quot;continue&quot;

5) The data goes to ther server back into the Select Case and if action = &quot;Continue&quot; then take the appropriate next step.

This is slow, I would use the client side solution with arrays or better yet use XML/XSLT.

 
many thanks for the response orsusnet - I did end up using the client side solution ansd it seems to work ok. However
I will try the above solution as well because I'm interested in being able to use the server side solution for future reference...I did'nt realise it could be donme this way using a hidden tag.

thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top