Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  134] [ 7]  / answers: 1 / hits: 25740  / 11 Years ago, sun, june 23, 2013, 12:00:00

This is going to be a stupid question but i need to ask it.
PS: this is an old practice but i need it this way.
In scriptlet I have a variable status.



 <%
String status=bean.getStatus();
//Status value is coming from database which is either 1 or 0(String type)
%>


In a form I have radio button.



<tr>
<td> Status :</td>
<td>Active
<input type=radio name=status checked=checked id=statusAct value=1 />
Inactive
<input type=radio name=status id=statusInac value=0/>
</tr>


If status==1 I want radio button with id=statusAct to be selected and if status==0 then radio with id=statusInac to be selected.



I can use javascript or Jquery but I don't know how to put Java variable inside javascript function.


More From » jquery

 Answers
10

You can simply do



<input type=radio name=status <% ${bean.getStatus() == '1' ? 'checked=checked' : '' } %> id=statusAct value=1 />


and



<input type=radio name=status <% ${bean.getStatus() == '0' ? 'checked=checked' : '' } %> id=statusInac value=1 />

[#77457] Friday, June 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emmaleet

Total Points: 203
Total Questions: 107
Total Answers: 98

Location: Cook Islands
Member since Thu, May 21, 2020
4 Years ago
emmaleet questions
Wed, Apr 28, 21, 00:00, 3 Years ago
Thu, Jan 7, 21, 00:00, 3 Years ago
Sat, Nov 28, 20, 00:00, 4 Years ago
Sat, Apr 18, 20, 00:00, 4 Years ago
;