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:
  #1  
Old October 20th, 2004, 12:17 AM
ramyaivan ramyaivan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 ramyaivan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Drop Down Click Event

hi
I want to populate a second dropdown with data from the database, based on the value or text selected inthe first dropdown.
The first and second dropdown are going to be in the same page, with the first dropdown being loaded with certain data from database
and the second dropdown will get populated only after clicking a value or text from the first drop down.
I have tried to write a code for this, but unfortunately its not working. Can anybody help me in resolving this problem.

My Code:
<html>
<body>
<form method="post" action="CustomerInformation2.php">
<?php
include ("DbConnection1.php")?>
<?
echo "<select id=\"DropName\" name=\"DropName\" onclick=\"CircuitInfo()\" method=\"post\">";
$sql = "select distinct CustomerID,CustName from Customer";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$varID=$row["CustomerID"];
$varName=$row["CustName"];
echo "<OPTION for=\"DropName\">".$varName.'</option>';
echo "<br>";
}
mysql_free_result($result);

/* This Function i have written to populate the second dropdown with data
from the database based on the text or value selected in the first dropdown*/

function CircuitInfo()
{
global $varID;
echo "<select id=\"DropCircuit\" name=\"DropCircuit\">";
$sql1="select CircuitID from Contract where CustomerID='".$varID."' ";
$res=mysql_query($sql1);
$opt="";
while ($row1=mysql_fetch_array($res)) {
$varcirID=$row1["CircuitID"];
echo "<OPTION for=\"DropCircuit\">".$varcirID.'</option>';
echo "<br>";
}
mysql_query($res);
}

?>
<input name="step" type="hidden" value="1" />
<input name="submit" type="submit" value="add"/>
</select>
</form>
</body>
</html>

Hoping for some positive results.

Thanking you
ri

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Drop Down Click Event


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 1 hosted by Hostway
Stay green...Green IT