user6656728
user6656728

Reputation:

check or uncheck radio buttons when i click on text

<input type="radio" name="allotdeallot" value="Allotment" />Allotment
<input type="radio" name="allotdeallot" value="De-Allotment" />De-Allotment

I have two radio buttons which I want to check or uncheck on label click.

Upvotes: 0

Views: 70

Answers (2)

Samir
Samir

Reputation: 1368

As per HTML standards, every form element must have label attach to it. You wish to hide the text of label, you can hide the text of the lable, by using position:absolute to the label. So here is your answer,

<input id="allotment" type="radio" name="allotdeallot" value="Allotment" /><label for="allotment">Allotment</label>
<input id="de-allotment" type="radio" name="allotdeallot" value="De-Allotment" /><label for="de-allotment">De-Allotment</label>

The id of the input field must be same with for attribute of the label.

Upvotes: 0

diiN__________
diiN__________

Reputation: 7656

Use the <label> tag and add the id attribute to the radio button:

<input type="radio" name="allotdeallot" id="allotment" value="Allotment" /><label for="allotment">Allotment</label>
<input type="radio" name="allotdeallot" id="deallotment" value="De-Allotment" /><label for="deallotment">De-Allotment</label>

More information

Upvotes: 1

Related Questions