Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Selected attribute in <select> list does not work.

I have this code. The result is given in the attached image:
<div class="row">
	<div class="col-sm-4 col-xs-4 text-right" style="padding-top:10px; font-size:20px"><b>Change Flow Rate (Optional):</b></div>
	<div class="col-sm-6 col-xs-6" style="padding-top:10px; font-size:20px"><select name="cfr">
			<option value="JPX-0004/FLG" >JPX-0004/FLG -$3,750</option>
			<option value="JPX-0010/FLG" >JPX-0010/FLG -$3,240</option>
			<option value="JPX-0016/FLG" >JPX-0016/FLG -$3,115</option>
			<option value="JPX-0028/FLG" >JPX-0028/FLG -$3,520</option>
			<option value="JPX-0038/FLG" >JPX-0038/FLG -$3,595</option>
			<option value="JPX-0060/FLG" >JPX-0060/FLG -$3,770</option>
			<option value="JPX-0085/FLG" >JPX-0085/FLG -$3,855</option>
			<option value="JPX-0130/FLG" >JPX-0130/FLG -$4,690</option>
			<option value="JPX-0200/FLG" >JPX-0200/FLG -$6,410</option>
			<option value="JPX-0285/FLG" >JPX-0285/FLG -$9,005</option>
			<option value="JPX-0450/FLG" >JPX-0450/FLG -$11,150</option>
			<option value="JPX-0650/FLG" selected='selected'>JPX-0650/FLG -$12,230</option>
			<option value="JPX-1160/FLG" >JPX-1160/FLG -$14,975</option>
			<option value="JPX-1850/FLG" >JPX-1850/FLG -$21,220</option>
			<option value="JPX-2650/FLG" >JPX-2650/FLG -$33,765</option>
			<option value="JPX-4200/FLG" >JPX-4200/FLG -$53,710</option>
			<option value="JPX-6700/FLG" >JPX-6700/FLG -$85,345</option>
		</select>
	</div>
</div>

Open in new window


I have tried just the word selected after the option value & what you see above. Neither works (nothing is selected) in Firefox?

This is NOT the first time I have had this problem.

Why does the item specified as selected NOT appear selected?
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Hey Richard,

The code you've posted is absolutely fine (tested in Firefox / Chrome / Edge). Do you have any other code in your page that could change the selected value, such as any jQuery event handlers etc.

FYI ... assuming your page is HTML (and not XHTML), you only need the selected attribute:

<option value="JPX-0650/FLG" selected>JPX-0650/FLG -$12,230</option>
Avatar of Richard Korts

ASKER

I reran it selecting a different model; works fine.

This sporadic behavior of that attribute is driving me crazy. Computers are deterministic machines. It is NOT magic.

Richard
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial