|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Syncronizing multiple select boxes to work together
Good Day! Does anyone have any experience or better yet have a snippet of code I could scrutinize which syncronizes select boxes to pull data from the same record from the table when you make a selection in the first. By way of further explanation I have a table called _clientsw_cases with three fields, CLNAME,CFNAME, and CASENUM. I want to set up three select boxes, one for each field. When the user selects the clients last name "CLNAME" from the first select box the second client first name "CFNAME" and the third casenumber "CASENUM" fill in automatically with information from the same record. Here is the code I am using for the first select box. My second select box would be CFNAME and the third would be CASENUM. I'm stuck!
Thanks for any advice or guidance in advance. <select name='CLNAME'> <?php $result = mysql_fetch_array(mysql_query("SELECT CLNAME FROM _clientsw_cases WHERE SNUM = '{$_SESSION['SNUM']}'")); $user_val = $result['CLNAME']; $query = mysql_query("SELECT * FROM _clientsw_cases"); while($array = mysql_fetch_array($query)) { if($array['id'] == $user_val) { print "<option selected value=$array[id]>$array[CLNAME]</option>"; } else { print "<option value=$array[id]>$array[CLNAME]</option>"; } } ?> </select> |
|
#2
|
|||
|
|||
|
I'm a bit confused, do you want the data to be filled in as soon as they select the name from the drop down box or is the form posted after the selection?
-KM- |
|
#3
|
|||
|
|||
|
I want the choices to fill the boxes immediately after the user makes his selection from the first box. Thanks
|
|
#4
|
|||
|
|||
|
javascript if u want automatically, or else it will have to be submitted, its really really easy to do it in javascript
|
|
#5
|
||||
|
||||
|
This gets asked almost weekly in the JS forum - search for dynamic option lists
|
|
#6
|
|||
|
|||
|
Dynamic Select Lists
Can anyone give me a handle on how to accomplish this in PHP when you post the form. I am trying to keep the application written in as much PHP as possible. Thanks! Appreciate the help
|
|
#7
|
|||
|
|||
|
When the form is posted get the id or whatever out of the combo box and put the value into your SQL statement. Use the result you get to populate your other combo box, and draw the page.
-KM- |
|
#8
|
|||
|
|||
|
An example would be nice!
Hey KM appreciate the guidance. But I am so new to this stuff haven't got any notion what the heck your talking about. Can you provide a simple example with remarks if its not too much trouble. Thanks
|
|
#9
|
|||
|
|||
|
I could but there are loads of examples of this kind of thing all over the internet. Have a look through some php tutorials on such topics and have a bash. Then when you have specific questions ask us here.
-KM- |
|
#10
|
|||
|
|||
|
The first thing you should try to figure out is if you want to accomplish this task:
a. On the client side (javascript only) or b. Serverside, by sending the info to php, then having it spit out the second drop-down's info. B. Is easier, A. is cleaner A. Requires you send everything needed, javascript picks up everything into Javascript arrays (or objects), then you iterate through the array, adding the items to the drop down. You use a function (or class method) to update the second drop down. You really should do this statically on a set of similar test data first... Then when you get the hang of what is supposed to be going on, you can make it dynamically in PHP.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Syncronizing multiple select boxes to work together |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|