471,108 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

Radio button selection in jsp

Hi All,

how to control the selection of radio buttons in jsp.
i think i have to write java script for that..
my code is like this
Expand|Select|Wrap|Line Numbers
  1. <form name="form1">
  2. <input type="radio" name="male">Male
  3. <input type="radio" name="female">Female
  4. <input type="submit" value="submit">
  5. </form>
  6.  
my problem is
if i select one radio button then i am not able to deselect it and
i am not able to select only one radio button.
how can i achieve it by using java script.

can anybody help me?
Jun 14 '07 #1
3 10876
JosAH
11,448 Expert 8TB
Hi All,

how to control the selection of radio buttons in jsp.
i think i have to write java script for that..
my code is like this
Expand|Select|Wrap|Line Numbers
  1. <form name="form1">
  2. <input type="radio" name="male">Male
  3. <input type="radio" name="female">Female
  4. <input type="submit" value="submit">
  5. </form>
  6.  
my problem is
if i select one radio button then i am not able to deselect it and
i am not able to select only one radio button.
how can i achieve it by using java script.

can anybody help me?
I thought that default behaviour is that you can only deselect a radio button by
selecting another radio button. If I remember well you can preselect a radio
button using the "selected" flag in it's tag.

You don't need Javascript for that; simply make your JSP generate the
appropriate html and you're in bizniz ;-)

kind regards,

Jos
Jun 14 '07 #2
epots9
1,351 Expert 1GB
Hi All,

how to control the selection of radio buttons in jsp.
i think i have to write java script for that..
my code is like this
Expand|Select|Wrap|Line Numbers
  1. <form name="form1">
  2. <input type="radio" name="male">Male
  3. <input type="radio" name="female">Female
  4. <input type="submit" value="submit">
  5. </form>
  6.  
my problem is
if i select one radio button then i am not able to deselect it and
i am not able to select only one radio button.
how can i achieve it by using java script.

can anybody help me?
give them the same name:
[HTML]
<form name="form1">
<input type="radio" name="gender">Male
<input type="radio" name="gender">Female
<input type="submit" value="submit">
</form>
[/HTML]

good luck
Jun 14 '07 #3
give them the same name:
[HTML]
<form name="form1">
<input type="radio" name="gender">Male
<input type="radio" name="gender">Female
<input type="submit" value="submit">
</form>
[/HTML]

good luck
it's working fine now..
thank u
Jun 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Craig Keightley | last post: by
3 posts views Thread by Chris Marsh | last post: by
2 posts views Thread by dpazza | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.