Jump to content

conditional drop boxes


samoht

Recommended Posts

hello all,

 

I wonder if anyone can send me in the right direction with setting up a pair of conditional drop boxes that is NOT from a database - but just using arrays??

 

I would like to load the second drop box based on a value selected in the first. I also know how to do this in javascript - but am not able to use js for the population in this case - because the name and id of the select boxes has been determined by a 3rd party software and they uses names that start with numbers (js doesn't seem to like that).

 

 

Link to comment
https://forums.phpfreaks.com/topic/160076-conditional-drop-boxes/
Share on other sites

hello all,

 

I wonder if anyone can send me in the right direction with setting up a pair of conditional drop boxes that is NOT from a database - but just using arrays??

 

I would like to load the second drop box based on a value selected in the first. I also know how to do this in javascript - but am not able to use js for the population in this case - because the name and id of the select boxes has been determined by a 3rd party software and they uses names that start with numbers (js doesn't seem to like that).

 

 

If you don't mind having the page refresh, you could have the user select their value from the first dropbox, have them submit the form with that value, then redisplay the form with the second dropbox based on that first box's value.

 

You could do something similar using AJAX, to remove the page refresh from the equation entirely, but that may be a bit more intensive than you need/want to do.

Thanks,

 

I understand that php is server side and that without ajax I'm looking at a page refresh. I am going to use ajax - but I wondered how to populate the second drop box?

can I just use arrays with a variable name that corresponds to the selection of the first drop box??

 

<?php
$xarray = array(xval01,xval02,xval03);
$yarray = array(yval01,yval02,yval03);
$zarray = array(zval01,zval02,zval03);

 

and then have a for loop to populate the second drop box with the array values that match the array chosen?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.