PHP dropdown list
Hi
I am a newcomer to PHP from a asp.net
I have 2 dropdown lists on my page, the first ia hard coded with 3 values, once selected I want the 2nd dropdown list to be populated based on whats selected in the first, the second list is to be populated from a mysql DB, I want to change the SQL command for it based on the option value selected in the first list. help please, i know code is messy, have been looking forums piecing together... any ideas please or even a simple example to steer me in the right direction!!
here is my code which sits in the form:
<td>Function Type:</td>
<td><select name="cat" onchange="return reload(this)">
<option value="">--------Select--------</option>
<option value="1" text="Hardware">Hardware</option>
<option value="2">Stationery</option>
<option value="3">System Module</option>
</select>
<select name="select_subcat">
<?php $cat=$HTTP_GET_VARS['select_fxn'];?>
<option value="" onchange=\"return reload(this.form)\">--------Select--------</option>
</select>
My Javascript:
function reload(thisform)
{
var val=document.forms['frm_regbarcode'].cat.options[document.forms['frm_regbarcode'].cat.options.selectedIndex].value;
self.location='ch_test.php?cat=' + val ;
alert(val);
// return true;
//alert('YOUR MESSAGE GOES HERE');
// return true;
}
function reload3(form)
{
var val=document.forms['frm_regbarcode'].cat.options[document.forms['frm_regbarcode'].cat.options.selectedIndex].value;
var val2=document.forms['frm_regbarcode'].select_subcat.options[document.forms['frm_regbarcode'].select_subcat.options.selectedIndex].value;
//form.select_subcat.options[form.select_subcat.options.selectedIndex].value;
self.location='ch_test.php?cat=' + val + '&select_subcat=' + val2 ;
}
__________________
Thank You
|