473,698 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parse value from 1 dropdown list to another list onChange event

2 New Member
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 3816
dlite922
1,584 Recognized Expert Top Contributor
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
5758
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> <option>Frog</option> etc etc and is in an include file... where the word i.e. worm sources the image ..images/worm.gif - simple so far...
10
7645
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 the onchange event isn't called when mouse wheel scrolling between A3 and B1, but it works properly when scrolling between A1 and A2. E.g. ------------------------------------------
2
12155
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 , suppose we put the same value in the text box then no event is fired. If we put some other value then it became fired... It wouldn't fire if we put the same value... I don't want to use onBlur etc... Isthere any solution with onChange Event...?
1
2751
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) txt.Attributes.Add("onchange", "return confirm('" & strMessage & "');") End Sub End Class
3
3980
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 a couple of problems, which I'll try to describe. But this e-mail will only reproduce one of them, in a "short" example. What I'm generally doing is having each form entry contained in a div, which as a label, an input with some event handlers,...
3
14837
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 page will reload then the inputs on my text field will disappear... sample HTML: <INPUT type="text" name="help_title" size="50"> <textarea cols="50" rows="15" name="help_content"></textarea> <select name="main_topic"...
21
29796
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 prodcut anme have used ajax to avoid refreshing of page this works fine 2.now i have created one row with checkbox|select box|text|text|text|text| where in the select box values are fetched from table here also i have used ajax for getting the m_name...
7
14501
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 event (not changing the option box value on relaod i.e. not re-running the SQL query). ONLY on initial entry should the form FIRST selection option box should be populated using JDBC SQL.
1
4373
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 first list the names of coresponding states in that country. For this I want to retrive values from database onchange event of the first drop down list. My code is: <HTML> <HEAD>
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.