File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 61092
    
  66

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]
 
 
subject: how to take javascript values into insert query in jsp?