Page 1 of 1

onChange Select did not display?

Posted: Wed Nov 14, 2012 12:00 am
by jayson.ph
Hi all,

please help -> what should the possible wrong in this part: since when i select the the list and it work okay. but after load the form the selected name is did not display and it return in default "Select Supplier".

Code: Select all

echo "<select name= 'product' onchange = 'reload(this.form)'> <option value = ''>Select Supplier..</option>";
			
					while($row_select_p = mysql_fetch_array($SQL_QUERY_PRODUCT_)) 
				{ 
						if($row_select_p['supplier_id']== @$product)
				{
				echo "<option value = '$row_select_p[supplier_id]'>$row_select_p[supplier_name]</option>";
					
				}
			else{echo  "<option value = '$row_select_p[supplier_id]'>$row_select_p[supplier_name]</option>";}

				}
			echo "</select>";
and also i already get the value if the id=> Image

Re: onChange Select did not display?

Posted: Wed Nov 14, 2012 2:15 am
by social_experiment
My understanding of what you want to achieve with the script: Have the selected item from the menu be the item that is selected when the page reloads. So if you select "Page", on the reload "Page" will be the item selected and not "Select supplier..."

Is this correct on my part?

Re: onChange Select did not display?

Posted: Wed Nov 14, 2012 7:40 am
by Mordred
You need to output a selected="selected" attribute in the <option> tag for the entry that is currently selected (first <option..> in your code)