/    Sign up×
Community /Pin to ProfileBookmark

dropdown sintax error?

Hi,

is there something wrong with this code?
Num must be the value selected. Consider that this is a dinamic form and i goes from 1 to 10. In this example I considered only one case.

[CODE]

function aaa(){

i=1;
fieldh=’day’ + i + ‘hh’;
num=document.forms[0].getElementById(fieldh).options[document.forms[0].getElementById(fieldh).selectedIndex].value;

}

<form name=”formname” method=”post” action=”file2.php” onSubmit=”return aaa()”>
<select name=”day1pp” id=”day1pp”>
<option value=”00″ selected>00</option>
<option value=”15″>15</option>
<option value=”30″>30</option>
<option value=”45″>45</option>
</select>

<input type=”submit” name=”go” value=”Go!”>
</form>
[/CODE]

Thanx!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gepngepinauthorMay 11.2004 — So it works!

num=document.getElementById(fieldh).options[document.getElementById(fieldh).selectedIndex].value;

?
×

Success!

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