syud_zack 0 Newbie Poster

hi all

i have several drop down list. the first 2 drop down list, works fine.

i have the problem when i want to display the data that has been selected from second drop down list into textbox..let say in the second drop down list, i choose rider_name : "Nabil Ismail", the next column which textbox, will display the phone number of the rider.

here parts of my code

<--form page (entryform2.php) -->

<?php include('db_connect.php'); ?>
<script language="javascript" type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getRider(club_name){		
		
		var strURL="findRider2.php?club="+club_name;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('riderdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
	function getRiderPhoneNumber(club_name,rider_name){		
		
		var strURL="findRiderPhoneNumber.php?club="+club_name+"&rider="+rider_name;

		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('riderPhoneNumberdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
function getHorse(owner_name){		
		
		var strURL="findHorse.php?owner="+owner_name;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('horsediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body>
<p>&nbsp;</p>
<table width="722" height="715" border="0" align="center" bordercolor="#04571a" bgcolor="#7DB04F">
  <tr height="107">
    <td><p>&nbsp;</p>
        <table width="385" border="0" align="center">
          <tr>
            <th width="125" scope="col"><div align="center"><img src="/epsb/logo_3qclassic2008.gif" alt="3qe" width="90" height="90" /></div></th>
            <th width="44" scope="col"><div align="left"></div></th>
            <th width="194" scope="col"><div align="center"><img src="/epsb/logo_epsb.gif" alt="epsb" width="180" height="90" /></div></th>
          </tr>
      </table></td>
  </tr>
  <tr>
    <td valign="center" align="middle"><p>&nbsp;</p>
        <p align="center"><font size="5"><strong><span class="style21">3QE CLASSIC 2008 <br />
          EQUESTRIAN COMPETITION<br />
          <font size="4">10 - 13 JULY 2008</font></span></strong></font></p></td>
  </tr>
  <tr>
    <td><table width="200" border="0" align="center" bgcolor="#2ED861">
      <tr>
        <td><span class="style1 style22"><strong>.:: NEW ENTRY FORM ::.</strong></span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="161" height="42" border="0" align="right">
      <tr>
        <th width="158" scope="row"><div align="left">
          <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','155','height','30','src','button22','quality','high','pluginspage','http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#7DB04F','movie','button22' ); //end AC code
                  </script>
          <noscript>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="155" height="30">
              <param name="BGCOLOR" value="#7DB04F" />
              <param name="movie" value="button22.swf" />
              <param name="quality" value="high" />
              <embed src="button22.swf" width="155" height="30" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#7DB04F" ></embed>
            </object>
            </noscript>
        </div></th>
      </tr>
    </table></td>
  </tr>
  <tr height="248">
    <!-- Row 1 -->
    <td height="449"><form id="form1" name="form1" method="post" action="">
      <table width="600" border="1" align="center" cellpadding="6" cellspacing="0" bordercolor="#C6BF93">
        <tr>
          <td width="205" bgcolor="#FFFFFF"><div align="right" class="style10 style25"><span class="style7">CLUB/COUNTRY</span></div></td>
          <td width="379" bgcolor="#C2F1BC"><select name="club" onChange="getRider(this.value)">
	<option value="">Select Club</option>
	<? 
			  mysql_select_db($database_link, $link);
			  $query_club = "SELECT * FROM club order by club_name ASC";
			  $club = mysql_query($query_club, $link) or die(mysql_error());
			  $row_club = mysql_fetch_assoc($club);
			  $totalRows_club = mysql_num_rows($club);

			  ?>
              <?php
do {  
?>
              <option value="<?php echo $row_club['club_name']?>"><?php echo $row_club['club_name']?></option>
              <?php
} while ($row_club = mysql_fetch_assoc($club));
  $rows = mysql_num_rows($club);
  if($rows > 0) {
      mysql_data_seek($club, 0);
	  $row_club = mysql_fetch_assoc($club);
  }
?>      
        </select>
              <a href="add_club1.php">Add New Club</a></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><div align="right" class="style26"><span class="style7">NAME OF RIDER</span></div></td>
          <td bgcolor="#C2F1BC"><div id="riderdiv"><select name="rider" id="rider">
            <option>Select Club First</option>
          </select>
              <a href="add_rider1.php">Add New Rider </a>&nbsp;</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><div align="right" class="style26"><span class="style7">RIDER CONTACT NO.</span></div></td>
          <td bgcolor="#C2F1BC"><div id="riderPhoneNumberdiv"><input name="riderPhoneNumber" type="text" id="riderPhoneNumber" /></div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><div align="right" class="style26"><span class="style7">OWNER NAME</span></div></td>
          <td bgcolor="#C2F1BC"><select name="owner" id="owner" onchange="getHorse(this.value)">
            <option value="">Select Owner</option>
            <? 
			  mysql_select_db($epsb, $link);
$query_owner = "SELECT * FROM owners order by owner_name ASC";
$owner = mysql_query($query_owner, $link) or die(mysql_error());
$row_owner = mysql_fetch_assoc($owner);
$totalRows_owner = mysql_num_rows($owner);

?>
            <?php
do {  
?>
            <option value="<?php echo $row_owner['owner_name']?>"><?php echo $row_owner['owner_name']?></option>
            <?php
} while ($row_owner = mysql_fetch_assoc($owner));
  $rows = mysql_num_rows($owner);
  if($rows > 0) {
      mysql_data_seek($owner, 0);
	  $row_owner = mysql_fetch_assoc($owner);
  }
?>
          </select>
              <a href="add_owner1.php"> Add Owner</a></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><div align="right" class="style26"><span class="style7">NAME OF HORSE</span></div></td>
          <td bgcolor="#C2F1BC"><div id="horsediv"><select name="horse" id="horse" >
            <option value="">Select Owner First</option>
          </select>
              <a href="add_horse1.php"> Add New Horse</a></div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><div align="right" class="style26"><span class="style7">HORSE NO</span></div></td>
          <td bgcolor="#C2F1BC"><input name="horseno" type="text" id="horseno" size="50" maxlength="10" /></td>
        </tr>
        <tr>
          <td height="38" valign="top" bgcolor="#FFFFFF"><div align="right" class="style26"><span class="style7">CLASS ENTRY</span></div></td>
          <td valign="top" bgcolor="#C2F1BC"><p>
            <input name="addrider2" type="button" id="addrider2" onclick="MM_openBrWindow('participantClass.php?ownerid=<?=$owner2?>','addrider','width=600,height=400')" value="Class Entered" />
            &nbsp;</p>
                <table border="1">
                  <? 
 $query_class = "SELECT * FROM class_details "; 
$class = mysql_query($query_class) or die(mysql_error()); 
$row_class = mysql_fetch_array($class); 
$totalRows_class = mysql_num_rows($class); 
 ?>
                  <?php 
$fields = mysql_num_fields($class); 
echo "<tr>\n";// dptkan nama medan 
echo "<td></td>\n"; 
for ($f=0; $f<$fields; $f++) 
{ echo "<td>".mysql_field_name($class,$f)."</td>\n"; } 
echo "</tr>\n"; 

do { ?>
                  <tr>
                    <td width="20"><input type="checkbox" name="class_id[]" value="<?php echo $row_class['class_number']; ?>" /></td>
                    <td width="71"><span class="style26"><?php echo $row_class['0']; ?>
                          </div>
                    </span></td>
                    <td width="57"><span class="style26"><?php echo $row_class['1']; ?>
                          </div>
                    </span></td>
                    <td width="64"><span class="style26"><?php echo $row_class['2']; ?>
                          </div>
                    </span></td>
                    <td width="64"><span class="style26"><?php echo $row_class['3']; ?>
                          </div>
                    </span></td>
                    <td width="64"><span class="style26"><?php echo $row_class['4']; ?>
                          </div>
                    </span></td>
                  </tr>
                  <?php } while ($row_class = mysql_fetch_array($class)); ?>
                </table></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td height="57" colspan="2" valign="top"><div align="right">
            <input type="submit" name="register" id="register" value="Save" />
            <input type="reset" name="Reset" value="Reset" />
          </div></td>
        </tr>
      </table>
    </form>
        <p align="center"><font color="#008000" face="Arial" 
      size="1"><strong><br />
          </strong></font><font face="Arial" 
      size="1"><strong><span class="style1">Copyright Reserved <br />
            Equestrian Promotion Sdn Bhd</span></strong></font></p></td>
    <!-- Col 1 -->
  </tr>
</table>
</body>
</html>
<--form findeRider2.php -->

<? 
$club=$_GET['club'];

include 'db_connect.php';

$query="SELECT rider_name FROM riders WHERE club_name='".$club."' order by rider_name ASC";

$result=mysql_query($query);

?>

<tr>
<td>
    <select name="rider" onchange="getRiderPhoneNumber(<?=$club?>,this.value)">
    <option>Select Rider</option>
    <? while($row=mysql_fetch_array($result)) { ?>  
    <option value=<?=$row['rider_name']?>><?=$row['rider_name']?></option>
<? } ?>
</select>
     <a href="add_rider1.php">Add New Rider </a>&nbsp;</div></td>
     </tr>
<--for findRiderPhoneNumber.php-->


<? 

$club =$_GET['club'];

$rider=$_GET['rider'];

include 'db_connect.php';

$query="SELECT rider_phone FROM riders WHERE club_name = '".$club."' AND rider_name='".$rider."'";

$result=mysql_query($query);

$row_rider = mysql_fetch_assoc($result);

$totalRows_rider = mysql_num_rows($result);

?>

<tr> 
<input name="riderPhoneNumber" type="text" id="riderPhoneNumber" value="<?=$row_rider['rider_phone']?>"
/>       
</tr>

i need help on this...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.