Link to home
Start Free TrialLog in
Avatar of ramsharma23
ramsharma23

asked on

How to tickmark the option in the Select box

I have select box in my application, when I will select particular option I have to tickmark (checked) that selected option. After selectiong again same option has to remove the tick mark(unchecked) the particular option.

Can you please provide me the some solution how to proceed.
ASKER CERTIFIED SOLUTION
Avatar of Batalf
Batalf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or do you mean a checkbox, instead of a select?

<input type="checkbox"> Some label here
Avatar of jessegivy
Well, I didn't come up with much.  The only concievable way to include a checkbox with your list box is to have a table cell next to your list box and have an array of checkboxes, one for each option tag.  Set the value attribute of each of these checkboxes to correspond to the value of the option tag.  It might work but seems a bit sloppy.  Lots of processing.  It would be sweet if there were an HTML character code for a checkmark.  Why aren't there more of those damn things???  Anyway if you need clarification let me know.  I think you could kill the border of the checkbox with the style attribute.

Good luck

JI
Avatar of NETTY4
NETTY4

Here a checkbox checker:

<html>
<head>
<script>
function checkMark(theBox){
  var allOpt = theBox.form[theBox.name];
  for(var i=0;i<allOpt.length;i++){
    allOpt[i].checked = false;
  }
  theBox.checked = true;
}
</script>
</head>
<body>
<form>
<input type=checkbox name="myOpt" value="A" onClick="checkMark(this)"> A<br>
<input type=checkbox name="myOpt" value="B" onClick="checkMark(this)"> B<br>
<input type=checkbox name="myOpt" value="C" onClick="checkMark(this)"> C<br>
<input type=checkbox name="myOpt" value="D" onClick="checkMark(this)"> D<br>
<input type=checkbox name="myOpt" value="E" onClick="checkMark(this)"> E<br>
<input type=checkbox name="myOpt" value="F" onClick="checkMark(this)"> F<br>
<input type=submit>
</form>
</body>
</html>