| | |
condition check of radio button
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2009
Posts: 1
Reputation:
Solved Threads: 0
i have two radio boxes in a jsp using html and i want to make one checked based on a condition. I can do that in php but i don't know how to do that using jsp. Can anyone help me.
These are the two radio buttons and based on the return value of this i want either one of them checked
JSP Syntax (Toggle Plain Text)
out.println("<tr><td>Billing Model"); out.print("<tr><td><input type='radio' name='appStatusDescription'value='0' >Prepaid<br>"); out.print("' </td>"); out.print("<td><input type='radio' name='appStatusDescription'value='1'>Postpaid<br>"); out.print("' </td></tr>");
These are the two radio buttons and based on the return value of this i want either one of them checked
JSP Syntax (Toggle Plain Text)
if((app.getBillingModel)==0)
Last edited by peter_budo; Apr 28th, 2009 at 5:49 pm. Reason: Correcting code tags, please use [code][/code]
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
JSP Syntax (Toggle Plain Text)
<html> <head> <script language="JavaScript"> function checkedOne(str) { var len=document.f2.appStatusDescription.length; for(var i=0;i<len;i++) { if(str==1) { if( document.f2.appStatusDescription[i].value==0) { alert("This code is going to the checked ,Prepaid radio button"); document.f2.appStatusDescription[i].checked=true; } } } } </script> </head> <body onLoad="checkedOne(1)"> <%-- here in checkedOne function you have to pass the parameter which is get from the server end means dynamic value , from that value you make the condition around the radio button --%> <form action="go" name="f2"> <tr> <td>Billing Model <tr><td><input type='radio' name='appStatusDescription'value='0' >Prepaid<br> </td> <td><input type='radio' name='appStatusDescription'value='1'>Postpaid<br> </td></tr> </form> </body> </html>
Last edited by amarjeetsingh; Apr 29th, 2009 at 2:38 am.
JavaScript is one option, but I would suggest to look into JSTL. That way if you need to set radio buttons as servlet require you have far easier quest
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
hi
peter,Can you tell me
how can i access the through the JSTL tag
peter,Can you tell me
how can i access the
HTML form element
•
•
•
•
hi
peter,Can you tell me
how can i access thethrough the JSTL tagHTML form element
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
hi
peter
i am talking about html form elements
like radio button,checkboxes,textbox
in a jsp page how can you access them
through jstl tags
as you mentioned in your previous answere
JavaScript is one option, but I would suggest to look into JSTL. That way if you need to set radio buttons as servlet require you have far easier quest
if you have answere to that question
then you should give the answere
peter
i am talking about html form elements
like radio button,checkboxes,textbox
in a jsp page how can you access them
through jstl tags
as you mentioned in your previous answere
JavaScript is one option, but I would suggest to look into JSTL. That way if you need to set radio buttons as servlet require you have far easier quest
if you have answere to that question
then you should give the answere
Last edited by amarjeetsingh; Apr 30th, 2009 at 6:09 am.
Could be simple like this
Where the values can be set by servlet, passed in session, retried by JSTL tags for session manipulation and then set in appropriated places
PS: sunscreencert, input tag have to be closed by "/" according to HTML4.0.1, see w3schools
<input type='radio' name='<c:out value="${param.name}"/>' value='1' checked='<c:out value="${param.checked}"/>' />
Where the values can be set by servlet, passed in session, retried by JSTL tags for session manipulation and then set in appropriated places
PS: sunscreencert, input tag have to be closed by "/" according to HTML4.0.1, see w3schools
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
but the original question was that
want to make one checked radio,
based on a condition
there are 2 radio button
when the jsp load from the server end
1 radio is checked on conditionally
how can i put the condition
on the jsp load
so
you put also use of
tags
around radio buttons
now Suppose you have 10 radio buttons
which is checked on conditionally
then how many condition put in jsp page
want to make one checked radio,
based on a condition
there are 2 radio button
when the jsp load from the server end
1 radio is checked on conditionally
how can i put the condition
on the jsp load
so
you put also use of
JSP Syntax (Toggle Plain Text)
<c:set var="s" value="${param.name}" /> <c:out value="${s}" /> <br> <c:if test="${s eq 'value of radio button' }">
tags
around radio buttons
now Suppose you have 10 radio buttons
which is checked on conditionally
then how many condition put in jsp page
Sessions is the answer, and before you ask about the use of sessions have look here (near the end you will find section on JSTL)
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
peter
this is the small application for school boys,
there is so many drawbacks
in your application
have you make any connection pool
in your tutorial
do n't ask what is connection pool
have you gave the ideas to the users
what will happen 1000 users connect your
small application
by the way in session
you should set minimum attributes
because due to this your site response can be slow
this is the small application for school boys,
there is so many drawbacks
in your application
have you make any connection pool
in your tutorial
do n't ask what is connection pool
have you gave the ideas to the users
what will happen 1000 users connect your
small application
by the way in session
you should set minimum attributes
because due to this your site response can be slow
![]() |
Similar Threads
- Problem with JavaScript!!! :( (JavaScript / DHTML / AJAX)
- Allowing multiple adds to SQL database (PHP)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- how to delete extra commas on csv file with php (PHP)
- Replacement of goto???? (JSP)
- hijack browser problem (hijack this file included) (Viruses, Spyware and other Nasties)
Other Threads in the JSP Forum
- Previous Thread: How can i know which submit was clicked
- Next Thread: javamail
Views: 2508 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






