Skip to content Skip to sidebar Skip to footer

How To Limit Checkbox Selections To One In A Html Document When The List Containing The Checkboxes Is Being Gennerated By .js

The intent is to use an html dialog box as a settings page for a program. In this settings page, the user can create a list of salespeople that can be selected later on from a drop

Solution 1:

Why not simply use a drop-down box, which only allows the user to select one of the sales people? This will greatly simplify the JavaScript as you will only need code to update the sales people in the drop down.

Solution 2:

I figured out how to limit their choices to one. As it turns out, I needed to be using radio buttons. Radio buttons buy default, only allow one to be selected. In order for this to work, the radio button will need to compare itself with all others of its kind to know if it's the only one checked. So to do this, I had to give all of the dynamically created radios the same name.

So I corrected this line:

'<td><inputtype="checkbox"class="defsales"</td>'+

To look like this:

'<td><inputtype="radio"name="ds"class="defsales" /></td>'+

Now all I need, is to figure out how to get the radio to display the saved selection at lunchtime.

Any suggestions?

Cheers,

Post a Comment for "How To Limit Checkbox Selections To One In A Html Document When The List Containing The Checkboxes Is Being Gennerated By .js"