PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old July 6th, 2004, 12:15 PM
Scot Scot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 29 Scot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old July 6th, 2004, 01:08 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 5
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-

Reply With Quote
  #3  
Old July 6th, 2004, 03:05 PM
Scot Scot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 29 Scot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 0
I want the choices to fill the boxes immediately after the user makes his selection from the first box. Thanks

Reply With Quote
  #4  
Old July 6th, 2004, 09:11 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
javascript if u want automatically, or else it will have to be submitted, its really really easy to do it in javascript

Reply With Quote
  #5  
Old July 7th, 2004, 12:55 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
This gets asked almost weekly in the JS forum - search for dynamic option lists
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #6  
Old July 7th, 2004, 08:15 AM
Scot Scot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 29 Scot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 0
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

Reply With Quote
  #7  
Old July 7th, 2004, 10:03 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 5
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-

Reply With Quote
  #8  
Old July 8th, 2004, 11:07 AM
Scot Scot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 29 Scot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 0
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

Reply With Quote
  #9  
Old July 8th, 2004, 12:13 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 5
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-

Reply With Quote
  #10  
Old July 9th, 2004, 09:12 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Syncronizing multiple select boxes to work together


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway