...

View Full Version : php call fuction oncahnge



Aymen++
05-15-2004, 03:20 PM
i have dropdown list when the user select it, the code will bring the information that correspond to the selected item:


<?
// connecting with database
$db =mysql_connect("localhost","root","");

//selecting db
mysql_select_db("project",$db)or die("Unable to select database project");

?>
<form name="make" avalue="<?php $PHP_SELF; ?> method="post">
<select name='selitems' onchange='this.make.submit()' >
<option value = "" >None</option>
<?
$sql = mysql_query("SELECT item_name FROM items");
for ($a = 0; $a < mysql_num_rows($sql); $a++) {
$array = mysql_fetch_row($sql);
echo "<option name='$array[0]' value='$array[0]'>".$array[0]."</option>";

}
if($value){
$result = mysql_query("select * from items where val = $item_name ",$db);
$myrow = mysql_fetch_array($result) or die(mysql_error());
echo "price".$array["a"];

}
?>
</select>
</form>

sidney
05-15-2004, 03:34 PM
try the below the on change need a form name to submit form and if you have a submit button make sure its not name submit

echo"<form name=\"form2\" method=\"post\" action=\"".$_SERVER['PHP-SELF']."\">";

echo "<select name=\"selitems\" onchange=\"document.forms['form2'].submit()\" size=\"10\">";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum