/    Sign up×
Community /Pin to ProfileBookmark

how to set an option in a listbox

dang javascript, how does one set a value in a dropdown listbox?

[CODE]
document.frmExam.weightAppliedTo.options[0].selected = true;
[/CODE]

[CODE]
<select name=’weightAppliedTo’>
<option value=” Selected></option>
<option value=’q’>This Quarter</option>
<option value=’s’>This Semester</option>
<option value=’y’>This Year</option>
</select>
[/CODE]

The first value in my listbox is “” and I want to reset it to that value in a function. What the heck is wrong with the syntax above?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@lcscneauthorJun 24.2004 — I hate to admit this but I wasn't calling the function to change the value, the syntax is fine and working, please disregard.
×

Success!

Help @lcscne 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.8,
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,
)...