Hey Guys,
I m new here. I need a help
I am working with a s/w where I need to fetch data from database onchange event.
actually scene is the user will select one option (ie. name of company) from the dropdown box. According to that value the s/w should run query and fetch that company's data from MySQL db and the fetched data will be displayed on its related textboxes. This all should happen onchange event itself
here is my code:
<form action='form1.php' method='post'>
<select name="<?="company".$a?>" id="<?="company".$a?>" onchange="search1()">
<option value=""></option>
<?
$comp_list = mysql_query("SELECT name FROM comp_name");
while($comp= mysql_fetch_array($comp_list) )
{
?>
<option value="<?=$comp[name]?>"><?=$comp[name]?></option>";
<?
}
$sel = $_REQUEST["company".$a];
$chk1 = mysql_query("SELECT date_modified, current_rate from price_tab where company = '$sel' and date_modified = (SELECT max(date_modified) from price_tab where model_no = '$model_no')");
$fet1 = mysql_fetch_array($chk1);
?>
</select>
<input type="text" size="15" name="<?="pre_date".$a?>" id="<?="pre_date".$a?>" value="<?=$fet1[date_modified]?>" readonly>
<input type="text" size="15" name="<?="pre_rate".$a?>" id="<?="pre_rate".$a?>" value="<?=$fet1[current_rate]?>" readonly>
<input type="text" size="15" name="<?="cur_rate".$a?>" id="<?="cur_rate".$a?>">
<?
$i++;
}
?>
<script language="JavaScript1.2" type="text/javascript">
function search1(val)
{
document.forms[0].action="search.php"
document.forms[0].submit();
}
</script>