|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Dynamic Select Boxes
I'm trying to control the contents of a select box based upon the selection of a first select box. I've done this before, the difference is that now I'm populating the JS arrays with PHP, which is slightly more difficult.
Anyway, this is the output of my PHP, which looks right, but it's not working. Can anyone tell me why this is failing? IE doesn't report an alert error anymore, nor does Mozilla Javascript console. php Code:
|
|
#2
|
|||
|
|||
|
RE: Dynamic Select Boxes
This is not really my forte... It took me a long time to get a similar setup to work, and I did it completely differently... I created a new Option objects to assign to the select.
something like: Code:
.
.
.
s=document.myform.uid;
s.options.length=0;//clear the options
s.options[s.options.length]=new Option('Person 1','Person 1');//key,value pair
s.options[s.options.length]=new Option('Person 2','Person 2');//key,value pair
s.options[s.options.length]=new Option('Person 4','Person 4');//key,value pair
.
.
.
Hope that helps... not sure if it will... good luck! -Jeff |
|
#3
|
|||
|
|||
|
RE: Dynamic Select Boxes
Jeff,
Could you post the rest of the code so I can try it out? Thanks a lot! |
|
#4
|
|||
|
|||
|
RE: Dynamic Select Boxes
Sure... but I won't get to it till tonight... it is on my home computer buried in some include file...
-Jeff |
|
#5
|
||||
|
||||
|
RE: Dynamic Select Boxes
it's really not that hard you can find a million examples of dependent select boxes on the web and then anywhere you need to put a dynamically created variable just replace the current string with
<?php echo $var; ?> if the length of the list is dynamic then you load the values into an array and step through with a for loop. one note of caution if you build too many dependent arrays either by having too many levels or too many elements per level this can really really impact loading. It's very easy to get a huge number of elements when you're dynamically building the arrays. |
|
#6
|
|||
|
|||
|
RE: Dynamic Select Boxes
I concur with bakertrg on the loading of the page issues. I found my old code but it was unnecessarily complicated. I created a simple example to illustrate what I was trying to say earlier:
http://jeff.caughel.net/js/index.php The source can be seen at: http://jeff.caughel.net/js/index.phps -Jeff |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Dynamic Select Boxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|