samoht Posted May 28, 2009 Share Posted May 28, 2009 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). Quote Link to comment https://forums.phpfreaks.com/topic/160076-conditional-drop-boxes/ Share on other sites More sharing options...
waynew Posted May 28, 2009 Share Posted May 28, 2009 PHP only works on the server, not on the client's side. Quote Link to comment https://forums.phpfreaks.com/topic/160076-conditional-drop-boxes/#findComment-844532 Share on other sites More sharing options...
KevinM1 Posted May 28, 2009 Share Posted May 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160076-conditional-drop-boxes/#findComment-844535 Share on other sites More sharing options...
samoht Posted May 28, 2009 Author Share Posted May 28, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/160076-conditional-drop-boxes/#findComment-844541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.