Some times we need to make the radio button going to be selected whenever the text near to the radio button is clicked.
For this kind of program we doesn’t need any javascript or anything. Even we doesn’t need the form.
The following example shows that method.
Use this code and leave the comments
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < html xmlns="http://www.w3.org/1999/xhtml" > < head > < meta http-equiv="Content-Type" content="text/html; charset=utf-8" / > < title > Untitled Document< /title > < /head > < body > < p > Try clicking on the text labels:< /p > < input type="radio" name="sex" id="male" / > < label for="male" > Male< /label > < br / > < input type="radio" name="sex" id="female" / > < label for="female" > Female< /label > < /body > < /html >
Note the above code name contain the same name for both label.But the id contain different name.So using that we can perform the function.
Use it and leave the comments to improve …
0 comments: