Jump to content

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?

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.