Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set and use a radio input on the same page without submit button  RSS feed

 
Jose Cuevas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I would like to do is use either a radio input or a "select" drop down to enter a value that I will later use in the same page. Here is a sample of what I have using radio input:

<tr><td><input type="radio" name="active" onchange= "<% request.setAttribute("active","IS NULL"); %>" checked>Active Teachers</td></tr>
<tr><td><input type="radio" name="active" onchange= "<% request.setAttribute("active","IS NOT NULL"); %>" >Inactive Teachers</td></tr>


<%
out.println(request.getAttribute("activeInactive"));
out.println(request.getAttribute("active"));
%>


The problem is that it will not recognize the checked radio, the out.println(request.getAttribute("activeInactive")); always comes out as NULL and the out.println(request.getAttribute("active")); comes out as "IS NOT NULL". It is like it is ignoring the checked radio.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are expecting the JSP code to be sensitive to the state of the radio buttons, then you have a basic misunderstanding of JSP and how it operates. The JSP code runs on the server long before the page gets sent to the browser where the buttons can be checked.

Please read this article to understand how JSP operates.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, is this a legacy page? If not, why is there Java code in the page? That's a practice that's been discredited and obsolete for over 12 years.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!