View Full Version : php call fuction oncahnge

05-15-2004, 04: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>";

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


05-15-2004, 04: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\">";