checkbox and select menu

is there a way to
have a 3 checkboxes and one select menu
with the same name

so when select menu is selected, there is no need to put a checkbox next to it
LVL 1
rgb192Asked:
Who is Participating?
 
jameso99Connect With a Mentor Commented:
This is not guaranteed to work in all browser and should be reviewed, but it was something I could whip up to show you an example of how you can use a select box to check checkboxes.

<script type="text/javascript">
function selectBoxes() {
  var x1 = document.getElementById('mySelectBox');
  var x2 = x1.options[x1.selectedIndex].value;
  if (x2 == "all") {
    for (i=0; i<document.test.checkgroup.length; i++) {
      document.test.checkgroup[i].checked = true;
    }
  }
  else {
    for (i=0; i<document.test.checkgroup.length; i++) {
      document.test.checkgroup[i].checked = false;
    }
  }
}
</script>

<form name="test">
<select id="mySelectBox" onChange="selectBoxes();">
<option value="">-- Select --</option>
<option value="all">Select All</option>
</select>
<input type="checkbox" name="checkgroup" />A
<input type="checkbox" name="checkgroup" />B
<input type="checkbox" name="checkgroup" />C
</form>

Open in new window

0
 
jameso99Commented:
They wouldn't need to have the same name, but you could use Javascript to check the box when the select field is selected.  For this each field needs its own ID value, and then the script would have to know which checkboxes are associated with the select field.
0
 
rgb192Author Commented:
I dont understand
0
 
Greg AlexanderLead DeveloperCommented:
No there is not, the post object would get overwritten so there would always only be the select menu's value being submitted.
0
 
rgb192Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.