hii every one,
i have an application containing data list.
datalist contains radio button as item template.i want only one radio button to be checked ie when the user clicks on one checkbox the other checkboxes should be unchecked.i have used groupname ,but no use .can any one give the solution to this problem.

9 Years
Discussion Span
Last Post by tamannashah

well, you can use checkboxlist but it doesn't work like radio buttons do. The user will be able to select multiple ones if you choose checkboxes instead of radio buttons. But if you decide to do checkboxes, use javascript to uncheck the other boxes in your group.

<script type="text/javascript">
function selectChkBox(field,checkit)
  for (i = 0; i < field.length; i++) {
	field[i].checked = false;
  checkit.checked = true;

then call it with an OnClick event like below:

<label><input type="checkbox" id="chkSelection" name="checkbox3" value="3" onclick="javascript:selectChkBox(document.formname.chkSelection,this.name)" />Checkbox 3</label>

I haven't tested it, but it should work. What it does is set all the checkboxes to unchecked, then checks the corresponding checkbox found by its name. Make sure that all your checkboxes are one ID (that are affected anyway), and then have each one a different name.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.