here is my php code which shows 2 drop down list the 2 drop down list retrives values from database but i want to add the selected values in the list box how can it be possible?? i m using ajax, php and mysql.
PHP Code:
<?php
$con = mysql_connect("localhost","user","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("info", $con);
/***********************website****************************/
$query = "SELECT DISTINCT website FROM urls1";
$result = mysql_query($query);
$str1 ="<select element=\"website\" onchange=\"htmlData('user.php', 'website='+this.value, 'elementresult')\">";
echo "<BR>";
while($rs = mysql_fetch_assoc($result)){
$str1 .= '<option value="'.$rs['website'].'">'.$rs['website'].'</option>';
}
$str1 .= '</select>';
/***********************element****************************/
$query = "SELECT element FROM urls1";
$result = mysql_query($query);
$str2 ="<select element=\"element\" onchange=\"htmlData('user.php', 'element='+this.value, 'websiteresult') onchange=elementresult(value) \">"; echo "<BR>";
while($rs = mysql_fetch_assoc($result)){
$str2 .= '<option value="'.$rs['element'].'"></option>';
}
echo "<BR>";
?>
<script language="javascript" type="text/javascript">
function CompanyNameCBtoTB(){
document.getElementById("website").value=document.getElementById("str1").value
}
</script>
<html>
<head>
<title>websites</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="ajax_req.js" type="text/javascript"></script>
</head>
<body>
<table>
<tr><td>
<form method="post" >
<div id="websiteresult"><?php echo $str1;?></div><br/><br/>
</td></tr>
<tr><td>
<div id="elementresult"><?php echo $str2;?></div><br/><br/>
<br/>
</td></tr>
<tr><td>
<input name="website" type="text" id="website" value="<?php echo $website ?>" size="60" readonly="true" />
</td></tr>
<tr><td>
</tr></td>
<tr><td>
<input type="submit"/>
</td></tr>
</form>
</table>
</body>
</html>
Bookmarks