/    Sign up×
Community /Pin to ProfileBookmark

Select object value


I just saw the following:

And wonder if there’s something wrong with [I]selectObject.value[/I]. Why not a simple approach:

<script type=”text/javascript”>
function displayResult()

Select your favorite fruit:
<select id=”mySelect”>
<option value=”apple”>Apple</option>
<option value=”orange”>Orange</option>
<option value=”pineapple”>Pineapple</option>
<option value=”banana”>Banana</option>

<button type=”button” onclick=”displayResult()”>Display value of selected fruit</button>


It seems to be working with no problem.

Thanks in advance!

to post a comment

1 Comments(s)

Copy linkTweet thisAlerts:
@nap0leonJun 10.2012 — What you have is exactly what they wrote.

selectObject = document.getElementById("mySelect")

You are using document.getElementById to get the object that you want the value of.


Help @Rain_Lover 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 11.28,
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: @bahaedd,
tipped: article
amount: 1000 SATS,

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

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