• 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

Radio Buttons

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I am having some dififculty with radio buttons. I have inserted them into my JSP page via java script.

<input type = "radio" poperty ="a" value = "b">

<input type = "radio" poperty ="a" value = "c">

When I submit them they are read in the action(using struts) and used to set certain boolens to true or false depending on which radio button is selected, this is done for sort of a permissions page. However, when I load the page all the radio buttons are unchecked. I would like to have them set to the ones previously selected. I could insert if statments to do this but trying to do it right not simply do it. I would also perfer to stay with the javascript as I will be moving away from the struts methodology.

Anyone have any ideas?

Thanks
 
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
If you're inserting them via JavaScript, then you'll need to track which value is selected via JavaScript as well.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So then somthing along the lines of inserting a js file and then preforming a radio button like

<input type = "radio" Name = "a" Value = "b" Checked = isChecked()>
 
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
Well, I'm not sure what that "isChecked()" bit is, but yes.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ischecked bit would just a potential java function name connected to the js file I would use to figure out whats what.
 
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
You can't call Java from a JavaScript file: Java is executed on the server; JavaScript is executed on the client (browser) after *all* the Java classes have been run and the JSP has been rendered.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats dumb you can do it in ASP!? Okay ill take your word for it I think im just going to try moving towards <html:radio> anyway ty for the 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
Well, you might be a little confused about how ASP works, unless you're talking about the Ajax extensions. Which could be duplicated.

It's not clear to me at all why you're building the radio buttons in JavaScript in the first place, though. You won't be able to build <html:radio> buttons in JavaScript, btw, for the same reason. You can mimic their rendered HTML, but you'll still have to set the value in JavaScript.

Maybe if you were a bit more descriptive in what you're trying to do this would be an easier discussion.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a JSP page ! Perhpas I just dont know what im doing lol which is probably most likley *shrugs* got to start somewhere.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ASP doesn't let you do anything on client that's "magic" any more than JSP does.

Like David, I really have no idea what you are actually trying to accomplish. Maybe it'd be best to step back a bit and explain that.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Obviously its not "magic" there is no need to be insulting because I dont understand, at one time you didnt. I have inserted .js files into my header before, and used them to hide forms when certain files are selected, and also use them for validation which is understandably different. But surely you could see how that could be confusing?

Thanks,
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
O for stepping back I probably have partially failed to explain correctly.

what I called Javascript where lines of code I inserted into my JSP page, which isnt java script when you think about it I just interpreted it as such. I think I need to look at it myself some more thanks for trying though guys!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Lark wrote:Obviously its not "magic" there is no need to be insulting because I dont understand, at one time you didnt.

If you found my post insulting, then you need to turn the gain on your Offense-o-Meter way down. We're trying to help you here. No insult is intended.

Sometimes people get too close to the problem, which is why you are being asked to step back a bit and explain the goals rather than the tactics.


 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lol your right sry!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Lark wrote:The ischecked bit would just a potential java function name connected to the js file I would use to figure out whats what.



Shouldn;t it say potential javaScript function

Java != JavaScript

eric
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay I was able to accomplish my original goal but I was wondering if yall could clarify for me.

If I put the command:

<input type = "radio" name = "test" value = "A">

into a jsp or asp page thats a java script command I thought?

If I put the command:

<html:radio Property = "test" Value = "test">

Then that should be a MVC or Stuts specific command is that not correct?


Thanks,
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Lark wrote:If I put the command:

<input type = "radio" name = "test" value = "A">

into a jsp or asp page thats a java script command I thought?


No, that's HTML.

And the proper term is markup, not command.

If I put the command:

<html:radio Property = "test" Value = "test">

Then that should be a MVC or Stuts specific command is that not correct?



That's Struts markup that's evaluated on the server. It gets turned into HTML before being sent to the browser.

MVC is a pattern, not a language.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic