View Full Version : Javascript and Select lists
RealTK
April 10th, 2005, 05:06 PM
I'm trying to achieve something that seems impossible.
I have a normal html Select list in a php file and what I'd like to do is keep
the selected value in the select list when the page refreshes instead of it jumping back to the first one. Anyone know how to do this with javascript or php?
nobody
April 10th, 2005, 05:49 PM
Well you can just use the option selected property. I think that'd do what you're looking for.
<option selected>whatever</option>
petefs
April 10th, 2005, 06:26 PM
If your doctype is XHTML, you'll need to use
<option selected="selected">whatever</option>
You might want to get into the habit anyway -- either will work, though : )
RealTK
April 10th, 2005, 08:50 PM
If your doctype is XHTML, you'll need to use
<option selected="selected">whatever</option>
You might want to get into the habit anyway -- either will work, though : )
Actually, I was looking for something to get the option stay as the one it was selected before refreshing the page. But I already got it working. :) I made it with a simple if in the loop where the select lists content is pulled from the database.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.