/    Sign up×
Community /Pin to ProfileBookmark

pulldown menu select question

Hi everyone,

I am trying to automatically select a value in a pulldown menu based on the result of a SQL query.

For example if I have:

[code=html]<select name=”test”>
<option value=”joe”>Joe</option>
<option value=”chris”>Chris</option>
<option value=”mike”>Mike</option>
</select>[/code]

I know you can select any of these using selectedIndex, but is there a way to select by the text value since this is the data stored in the Database?

Basically I need a script that if the value is set to “mike” it selects mike (selectedIndex 2). The selection list in question is huge (over 100 records and changes often).
Thanks!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@afailauthorJun 07.2006 — bump
×

Success!

Help @afail 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...