473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

parse value from 1 dropdown list to another list onChange event

hi guys, need your expertise...

I'm trying to create a list for group of associates by group and when a group is selected the associates assigned to that group will appear in a list

sample
Expand|Select|Wrap|Line Numbers
  1.  
  2. <select name="groupName">
  3. <?php $rs_groupSearch="SELECT * FROM tblGroup";
  4. $groupCount=mysql_num_rows($rs_groupSearch);
  5. if($groupCount>0){
  6.    while($Groups=mysql_fetch_array($rs_groupSearch)){
  7. ?>
  8.     <option><?php echo $Groups['GroupName']; ?></option>
  9. <?php } else { ?>
  10.     <option>No Groups in List</option>
  11. <?php } ?>
  12. </select>
  13.  
when user select a group then it will display the names of the selected group members (the above code works fine)

Expand|Select|Wrap|Line Numbers
  1.  
  2. <select name="groupMembers" size="4">
  3. <?php $rs_groupMemberSearch="SELECT * FROM tblGroupMembers 
  4. WHERE GroupName='$groupName'"; //This is where i'm stuck 
  5. //$groupName is the name of list box above i don't know 
  6. //how to parse the value from that list to this sql
  7. $groupMemberCount=mysql_num_rows($rs_groupMemberSearch);
  8. if($groupMemberCount>0){
  9.    while($GroupMembers=mysql_fetch_array($rs_groupMemberSearch)){
  10. ?>
  11.     <option><?php echo $Groups['MemberName']; ?></option>
  12. <?php } else { ?>
  13.     <option>No Members in List</option>
  14. <?php } ?>
  15. </select>
  16.  
Note: I would like to do this without hitting the submit button just like how other website do their country,state drop down list. I don't mind having the list to submit itself

i have tried some examples from the net but its not working
Jun 2 '10 #1
1 3803
dlite922
1,584 Expert 1GB
Hey Ryangsh,

Lists don't submit themselves, lists can call javascript functions with their event handlers (onclick, onchange, onblur, so on)

So in one of these, you're list can submit the form, and therefore the list's selected value to a (php) script on the server.

The server can then know what is selected and reply back with a /new/ page (or the same page with added content), which of course this would be the name of the associates in that selected group.

This, as you may have already guessed, does a call to the server and refreshes the page, which is something you like to prevent I assume.

So the only technology that I know that can do this without refresh is called AJAX, or shortly Asynchronous Javascript.

AJAX is just fancy Javascript code that does a call to the server behind the scenes and can parse the data returned from the server. Of course the "thing" returned can't be another page, your php should as an example, return a list of names with commas in between them and NOTHING more.

This way, Javascript code can then parse the names and put them in any element on your HTML page, All in a blink of an eye!

Learn Javascrip/AJAX and forward any questions you have to the appropriate forum, If you get stuck in the PHP code, feel free to come back here.

Cheers,




Dan
Jun 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lee Mundie | last post by:
Hi there, Simple problem here but can't seem to fix it! Okay, I have a select list from which people choose avatars... the list is option values ie. <option>Worm</option> ...
10
by: Ryan McGeary | last post by:
In a <select> drop-down, the onchange event isn't called when scrolling through the dropdown using the mouse-wheel and when crossing over a new <optgroup>. Using the example below, notice how...
2
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time ,...
1
by: MDBloemker | last post by:
can anyone help me fathom out how to use this bit of code: Public Class Utilities Public Shared Sub CreateConfirmBox(ByRef txt As WebControls.TextBox, _ ByVal strMessage As String)...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
3
by: countocram | last post by:
hi! Im having a problem retaining the inputs on my text fields. When i selected an option from a dropdown list with an onChange=location.. event. What happen is that, everytime I choose an option the...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
7
by: robtyketto | last post by:
Greetings, I'm slowly building up code to do the following:- Display TWO selection option boxes (cascading). If the FIRST selection option box changes then reload the jsp using onchange...
1
by: ruds | last post by:
Hello, I have a JSP page in which HTML form elements are present. I have a drop down list named Country, when a user selects his country I want another drop down list to populate based on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.