/    Sign up×
Community /Pin to ProfileBookmark

Default Dropdown Menu Item

Hello all, I have another question related to a hurry-up job.

How can you set a drop down menu to a default selection? Here’s the specific menu code, and its in a form:

<td width=”116″ align=”right” class=”style14″>Select Your State </td>
<td width=”320″ align=”left”><select name=”selectstate” id=”selectstate”>
<option value=”Alabama”>Alabama</option>
<option value=”Florida”>Florida</option>
<option value=”Georgia”>Georgia</option>
<option value=”North Carolina”>North Carolina</option>
<option value=”South Carolina”>South Carolina</option>
</select>
</td>

What do I need to add to make the selection drop down menu default to one state or another, or is there a link I can go to to accomplish this?

Thanks in advance ?

Cheers,
Garth P.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 13.2006 — &lt;script type="text/javascript"&gt;
window.onload=function() {
document.getElementById('selectstate').options[[COLOR=Green]anIndex[/COLOR]].selected=true;
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@GarthPauthorJan 14.2006 — Thanks Fang. Now where in the code snippet I provided should I put that code that you gave? Or do I put it outside my snippet? Could you elaborate a little bit please?

Thanks. ?

Cheers,

Garth P.
Copy linkTweet thisAlerts:
@felgallJan 14.2006 — Why not just hard code it in the HTML

<td width="116" align="right" class="style14">Select Your State </td>

<td width="320" align="left"><select name="selectstate" id="selectstate">

<option value="Alabama">Alabama</option>

<option value="Florida">Florida</option>

<option value="Georgia" [b]selected[/b]>Georgia</option>

<option value="North Carolina">North Carolina</option>

<option value="South Carolina">South Carolina</option>

</select>

</td>
×

Success!

Help @GarthP spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...