/    Sign up×
Community /Pin to ProfileBookmark

how to set values for select tag?

Hi,

I have a select tag with multiple selections, like this:

<select name=”cars” value=”carArray” size=”4″ multiple>
<option value =”volvo”>Volvo</option>
<option value =”saab”>Saab</option>
<option value =”opel”>Opel</option>
<option value =”audi”>Audi</option>
</select>

now I have a resulting string array – carArray – I got from server-size, which contains, say “Volvo” and “Audi”. I used value=”carArray” as shown above trying to set select tag values with this array, nothing happens. I am wondering how I can set select values so that Volvo and Audi will be selected?

regards,

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@thewebmanMar 10.2006 — it would help to know what language you're trying to do this in. in JavaScript, you would use document.formName.cars.value that would return the user's selection.
Copy linkTweet thisAlerts:
@ray326Mar 10.2006 — I'd do it on the server while the options are being generated.
×

Success!

Help @rick_cols 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.20,
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,
)...