Jump to content

dynamic select menus


ksmatthews

Recommended Posts

I want to create 2 select menus - one static (Menu 1) and the other (Menu 2) populated according to the selection made in Menu 1.

Data will will be pulled from a CSV file.

 

Menu 2 will not have any values in it until an option from Menu 1 has been selected. Then, the options available will be limited based on the Item 1 selection.

PHP must be used to read the CSV file and to capture the data (using arrays)

 

I met this problem before and my approach then was to call a function using the onChange event for Menu1 ...

 

<script type = "text/javascript">function update_select(obj){     

  window.location.href="./call_stats_main.php?choice=" + obj.value;}

</script>

 

onchange="update_select(this)

 

This would reload the page passing a parameter to the URL (?choice=)

 

I could then use $_GET['choice'] to capture the selected value and dynamically populate Menu 2 according to this value.

 

It is the onchange event that triggers the population of menu 2.

 

I would like to know IF THERE IS A BETTER WAY, other than using ajax ?

 

Steven M

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.