Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate dropdown with checkbox selections

Status
Not open for further replies.

Diggum1

Programmer
Oct 14, 2004
67
US
I have a form that contains 2 questions. The first question has up to 20 checkbox selections.

The second question contains a dropdown (select menu) that I would like to have dynamically populated by the items that were checked in the previous question.

I'm not sure how to do this. Any ideas or sample code?

Thanks, Rick
 
Show us what you have already. What exactly does the assignment require?

Lee
 
Here's what I have. It's not much.

<body>
<div id="Question1">
<p>What are your reasons for signing up? </p>
<p>
<input name="Reasons" type="checkbox" id="Reasons" value="Samples" />
Free Samples <br />
<input name="Reasons" type="checkbox" id="Reasons" value="Coupons" />
Coupons <br />
<input name="Reasons" type="checkbox" id="Reasons" value="Money" />
Save Money </p>
</div>

<div id="Question2">
<p>Which reason is the most important?</p>
<p>
<select name="select">
<option>Select</option>
</select>
</p>
</div>


</body>


I'd like to populate the select menu in Question2 with the items selected in Question1. In theory, I would create an array from the check box selections, then populate the dropdown from the array.

Just not sure how to do it.

Thanks
 
There is no teacher, this is a real-world request from a client :)
 
This type of question gets asked a lot in this forum. So much that a couple of FAQs have been written on the subject. Rather than type out the example it would probably be faster for all of us for you to check there. (link at the top of this page)

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
 
I didn't really see any FAQ that fit my needs. I'll keep plugging along. Thanks anyway.
 
They're there, you just need to look a little harder:

faq216-4766
faq216-6294
faq216-335

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
 
The faqs won't exactly have the answer to your specific question. They have some faqs on working with check boxes and some on select lists. You need to combine both examples/scripts to get your desired results. It will be harder to find a faq or a page that solves exactly your problem than it is to find examples that address the broader topics covered in your problem. I doubt someone wrote a working example of "how to populate select list options from check boxes". When you do any type of research you need to find a few sources that cover your topic. Take for example a specific species of fish. Most libraries won't have a book exactly on your fish species but will carry books on fish in general and maybe some books that cover all fish belonging to the same family. It is mostly up to you to research the solution. So while your exact question may not be answered, the topics are covered both here and in Google searches. Figure out how to get the values from a group of check boxes and how to populate a select list, get some kind of code and if you can't figure out exactly how to piece it together, I'm sure most of the regular posters will happy to help.
 
That's actually what I've been doing - trying to put those two pieces together (making an array of check box values, then using that array to populate a select box). Let's see where it gets me.

Thanks for the replies...
 
j4606 is right, I figured the faqs wouldn't have a copy/paste solution for you, but they'd definitely address the concepts that you'd need to understand to solve the problem. [thumbsup2]

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top