It's not a secret anymore!*
The moose likes JSP and the fly likes setting a page element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "setting a page element" Watch "setting a page element" New topic
Author

setting a page element

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hello everyone,
I have several radio buttons, and I'd like to set one of them to "checked" based on the value of request. Thanks in advance. So here is what I have so far:
<INPUT type="radio" name="C5" value="Plus">
<INPUT type="radio" name="C5" value="Plus To Max">
<INPUT type="radio" name="C5" value="Fixed">
<INPUT type="radio" name="C5" value="Other">
<%
if (request.getParameter("radio")!= null){
String c = request.getParameter("radio");

}
%>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

You need to place the string checked="checked" on the input element that is to be checked.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
I'm sorry, I'm new to jsp. Could you please tell me what the syntax would look like for what you're talking about?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

As per the forum instructions, what sever are you using, and what version of JSP?
Rodrigo Alvarez
Ranch Hand

Joined: Apr 10, 2006
Posts: 75
maybe something like this :




or not?


It is a mistake to think you can solve any major problems just with potatoes.<br />--Douglas Adams
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

Not. Adding the checked attribute to the element, regardless of its value, turns the checked property on.

The best sytnax to use will depend on the answer to my question regarding JSP version. EL for JSP 2.0, a scriptlet expression otherwise.
 
wood burning stoves
 
subject: setting a page element