• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to take javascript values into insert query in jsp?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic