Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

checkbox

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everybody
on my servlet which generates a html page there r three radio buttons & one submit button
when i click on submit i want to detect which radio button is selected.& calculate
the no of times it is selected.if i am not selecting any option
message should come.pls reply soon.
Sejal
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i cant understand what do meant by "calculate the no of times it is selected "
will you please explain a little more.
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guessing you mean that you want to have a set of radio buttons and have the value (the number) of the selected radio passed when the form is submitted. If so, here's how to do it.
<FORM METHOD=POST ACTION="http://Some url">
<INPUT TYPE="radio" NAME="myRadios" VALUE="1"> radio1<BR>
<INPUT TYPE="radio" NAME="myRadios" VALUE="2"> radio2<BR>
<INPUT TYPE="radio" NAME="myRadios" VALUE="3"> radio3<BR>
<INPUT TYPE="submit">
</FORM>
Now, because the radio buttons have the same name they will act like radio buttons and not checkboxes (i.e. you will only be able to select one). When one is selected and the form is posted then the name "myRadios" will have the value of the selected radio button (1, 2, or 3 in this case). So if you ask for the value of "myRadios" you will get the value of the one selected. You can set one of them as a default by doing this.
<INPUT TYPE="radio" NAME="myRadios" VALUE="1" CHECKED> radio1<BR>
I hope this helps.
Sean
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic