wood burning stoves 2.0*
The moose likes JSP and the fly likes how to take javascript values into insert query in jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to take javascript values into insert query in jsp?" Watch "how to take javascript values into insert query in jsp?" New topic
Author

how to take javascript values into insert query in jsp?

neha agg
Greenhorn

Joined: Sep 30, 2012
Posts: 4
while(rs.next())
{

String id=rs.getString("id");
String question=rs.getString("question");
String option1=rs.getString("option1");
String option2=rs.getString("option2");
String option3=rs.getString("option3");
String option4=rs.getString("option4");
String answer=rs.getString("answer");
%>

<form name="f1">
<%= id %> <%= question %> <br/>
<input type="radio" name="op1" id="op11" value="<%= option1%>" /> <%= option1 %> <br/>
<input type='radio' name="op1" value="<%= option2%>" /> <%= option2 %> <br/>
<input type='radio' name="op1" value="<%= option3%>" /> <%= option3 %> <br/>
<input type='radio' name="op1" value="<%= option4%>" /> <%= option4 %><br/>
<input type='submit' name='btn' value='click' onclick="call()"/>
</form>


<script>
function call()
{

var selection = document.f1.op1;

for (var i=0; i<selection.length; i++)
if (selection[i].checked == true)
document.write(selection[i].value); //how to take this value in inser query in jsp



System.out.println("inserted");

}


</script>



<%


break;

}

please help!!!
document.write(selection[i].value); //how to take this value in inser query in jsp
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

You can't. The JSP executes on the server long before the JavaScript executes on the client after the page is sent to the browser. Please read this JspFaq entry for more info.

Also, using Java code in a JSP is a poor and obsolete practice from over 10 years ago. Please read this JspFaq entry.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to take javascript values into insert query in jsp?
 
Similar Threads
Comparing value of radio button against answer from the database
Show a hidden text field
JSP Pagination not working
Inter Frame communication in quiz application
Struts 2 <s:submit action > and javascript help