View Full Version : Drop-Down Get Return From Default

07-11-2012, 03:27 AM
Hi All,

i just ask why? when i select record from the drop-down-list it will return to a default netbook. see image below


as you notice i select category and it success to change from the address bar. but i wonder why in the circle portion it return to a default netbook. here my code.

var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='insert_request.php?cat=' + val ;

$query = "SELECT DISTINCT cat_name,cat_it FROM tbl_category";
$x = mysql_query($query);

echo "<p>Category:<select name ='cat' onchange=\"reload(this.form)\">";
while($v = mysql_fetch_array($x))
echo "<option value = $v[cat_name]> $v[cat_name]</option>";

echo "</select></p>";

07-11-2012, 08:25 AM
because you are not telling it to ...

if($v['cat_name']) {
$s=$v['cat_name']==$_GET['cat'] ? 'selected="SELECTED" ' : '' ;
echo "<option $s value =\"{$v['cat_name']}\"> {$v['cat_name']}</option>";