/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Update hidden filed

I have

[code=html]<select name=”Unit” id=”Unit” size=”1″>

<option> — Choose — </option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>[/code]

How can I populate a hidden field the value that is chosen in list above?

[code=html]<input type=”hidden” id=”test” name=”test” value=”??”;>
[/code]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 11.2009 — &lt;select name="Unit" id="Unit" size="1" [COLOR="Blue"]onchange="document.getElementById('test').value=this.value"[/COLOR]&gt;

<i> </i> &lt;option [COLOR="Blue"]value=""[/COLOR]&gt; -- Choose -- &lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="1"[/COLOR]&gt;1&lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="2"[/COLOR]&gt;2&lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="3"[/COLOR]&gt;3&lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="4"[/COLOR]&gt;4&lt;/option&gt;
<i> </i> &lt;/select&gt;
Copy linkTweet thisAlerts:
@martin111authorMay 11.2009 — &lt;select name="Unit" id="Unit" size="1" [COLOR="Blue"]onchange="document.getElementById('test').value=this.value"[/COLOR]&gt;

<i> </i> &lt;option [COLOR="Blue"]value=""[/COLOR]&gt; -- Choose -- &lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="1"[/COLOR]&gt;1&lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="2"[/COLOR]&gt;2&lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="3"[/COLOR]&gt;3&lt;/option&gt;
<i> </i> &lt;option [COLOR="Blue"]value="4"[/COLOR]&gt;4&lt;/option&gt;
<i> </i> &lt;/select&gt;
[/QUOTE]


I have your code first, then I have my own code,

[code=html]<input type="hidden" id="test" name="test" value="";>[/code]

Do I then remove the value that I have given this hidden field?

Because it my hidden field is empty
Copy linkTweet thisAlerts:
@FangMay 11.2009 — It's initial value can be anything you like.
Copy linkTweet thisAlerts:
@martin111authorMay 12.2009 — That works great, thank you very much. ?
×

Success!

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