• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Selected radio button value to be send to action class

 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a radio button which retrieves value from the property of a form. I need to send the value of the radio button to the action class?How can i do that? I need to send the value of only the selected radio button and not all. Can i do it <html:hidden> tag? If yes, how?

Also how to send the label of the radio button selected? Label of a particluar radio button is also populated from the property of a form?
 
author & internet detective
Posts: 41905
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maan,
The value of the selected radio button is already submitted. If you need the label too, you do need a hidden field.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne....

But it would have been great if you could expain this to me with a small example....

As i am not very clear....
What iam doing is iam selecting a radio button and clicking submit.

My code is something like as mentioned below
<logic:iterate>
<for label>
//below is for label

<bean:write name="abcForm" propery=empid>

//below is the radio button and its value

<html:radio name="currenty i dont care" id="currently idontcare" value=<%="empName.toString" />
</logic:iterate>

Both empName and empid are properties of the form.


My code is something like above, if not exactly the same...
Now i select a radio button from the list of radios displayed ,and clicks submit.

On click of submit, it calls javascript, form where it forwards to a particular action class.Then question here is how can i send both "empId" and "empName" values?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This seems less a Struts question than a JavaScript question, no?
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok...it is...but i kept it here as i thought we are populating the values of radio button etc through struts tags. Anyways , can anyone please help?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...

I guess you'd have to set the onclick handler of the radio button to a JavaScript function that sets the hidden field with the value of the name.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Now i will just try to show how its gets displayed on the screen (just look and feel)

EmpID 0200110035 o Manish
EmpID 0200110093 o Rajesh

Now suppose i select the first radio button , then i am able to retrieve value of it (i.e here 'Manish') , but NOT the label '0200110035'


 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure there is.

Look: you're asking how to do something in JavaScript, which isn't Struts. *You* have to build the JavaScript method call that sets the hidden field with the employee name. Here's some pseudo-code:OTOH, if you have the empId, it would seem like you don't really need the empName.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic