/    Sign up×
Community /Pin to ProfileBookmark

checkbox to fill in several selectboxes

Hello,

[code=html][/code]

First of all I don’t know much about javascript so please forgive me is my problem is to easy… (it does’t seem easy to me ? )

I have 4 selectboxes:

[code=html]
<select name=a><option value=1>x</option><option value=2>y</option>…</select>
<select name=b><option value=1>x</option><option value=2>y</option>…</select>
<select name=c><option value=1>x</option><option value=2>y</option>…</select>
<select name=d><option value=1>x</option><option value=2>y</option>…</select>
[/code]

How can I make a checkbox that once selected it will fill in the rest of the selectboxes with the option selected in one of the selectboxes?

I mean if I set the first selectbox (a) to option 2 and click the checkbox, the rest of the selectboxes (b,c,d) will change to option 2?

Can anyone help or at least give me a good example to follow since my google searches got me nowhere ?

Thanks a lot!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJun 17.2009 — See post #4 of: http://www.webdeveloper.com/forum/showthread.php?t=210885&highlight=checkboxes

Is that what you are after or do you really mean selectboxes as you stated. ?
Copy linkTweet thisAlerts:
@jakauthorJun 17.2009 — See post #4 of: http://www.webdeveloper.com/forum/showthread.php?t=210885&highlight=checkboxes

Is that what you are after or do you really mean selectboxes as you stated. ?[/QUOTE]


nope... that's not it. That example is all about checkboxes.

I need a checkbox that will set values to all the selectboxes based on what is selected in one of them...
Copy linkTweet thisAlerts:
@JMRKERJun 17.2009 — OK, then try this...
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Check Selections&lt;/title&gt;
&lt;script type="text/javascript"&gt;
// From: http://www.webdeveloper.com/forum/showthread.php?p=1014747#post1014747

function SetSBoxes(info) {
if (info.checked == true) {
var sel = document.getElementById('SBox1').selectedIndex;
document.getElementById('SBox2').selectedIndex = sel;
document.getElementById('SBox3').selectedIndex = sel;
}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Check box - Select box initializtion&lt;/h1&gt;
&lt;select id="SBox1"&gt;
&lt;option value=""&gt;Select&lt;/option&gt;
&lt;option value="1"&gt;1&lt;/option&gt;
&lt;option value="2"&gt;2&lt;/option&gt;
&lt;option value="3"&gt;3&lt;/option&gt;
&lt;option value="4"&gt;4&lt;/option&gt;
&lt;option value="5"&gt;5&lt;/option&gt;
&lt;/select&gt;
&lt;input type="checkbox" onclick="SetSBoxes(this)"&gt;Set Rest
&lt;select id="SBox2"&gt;
&lt;option value=""&gt;Select&lt;/option&gt;
&lt;option value="1"&gt;1&lt;/option&gt;
&lt;option value="2"&gt;2&lt;/option&gt;
&lt;option value="3"&gt;3&lt;/option&gt;
&lt;option value="4"&gt;4&lt;/option&gt;
&lt;option value="5"&gt;5&lt;/option&gt;
&lt;/select&gt;
&lt;select id="SBox3"&gt;
&lt;option value=""&gt;Select&lt;/option&gt;
&lt;option value="1"&gt;1&lt;/option&gt;
&lt;option value="2"&gt;2&lt;/option&gt;
&lt;option value="3"&gt;3&lt;/option&gt;
&lt;option value="4"&gt;4&lt;/option&gt;
&lt;option value="5"&gt;5&lt;/option&gt;
&lt;/select&gt;

&lt;/body&gt;
&lt;/html&gt;

Add additional checks if the select boxes are NOT all the same size.

?
Copy linkTweet thisAlerts:
@jakauthorJun 18.2009 — thanks a lot. it's exactly what I needed!
Copy linkTweet thisAlerts:
@JMRKERJun 18.2009 — You're most welcome.

Glad I was able to help with clarifications.

Good Luck!

?
×

Success!

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