Results 1 to 7 of 7
- 06-14-2011, 09:55 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 9
- Rep Power
- 0
using java code inside javascipt-- in jsp
i am nt able to post d marks obtained by a student to the corresponding database. i have used javascript to handle the onsubmit event of the form, bt im nt able to retain the javascript's variable's value in my java code.
here z d code..
<script language="javascript">
function f11()
{
alert("entererddd");
var result=0;
x= document.f1;
if(x.r1[0].checked || x.r1[1].checked || x.r1[2].checked || x.r1[3].checked)
{
if(x.r1[0].checked)
{
alert("monkey");
result=result+1;
result1=result1+1;
alert(result1);
}
if(x.r1[1].checked)
{
alert(" dog ");
}
if(x.r1[2].checked)
{
msgbox("hello");
System.out.println("chekd here");
alert("donkey ");
}
if(x.r1[3].checked)
alert("cat ");
}
if(x.r2[0].checked || x.r2[2].checked || x.r2[3].checked || x.r2[1].checked)
{
alert("2nd entrd");
if(x.r2[0].checked)
{
alert("crab");
result=result+1;
result1=result1+1;
}
if(x.r2[1].checked)
alert("snake");
if(x.r2[2].checked)
alert("dog");
if(x.r2[3].checked)
alert("cockroach");
}
alert(result);
}
</script>
</head>
<BODY bgcolor="red">
<H1> <center>ONLINE MCQ EXAM</center></H1>
<H2> QUESTION1: </H2>
<b>NATIONAL ANIMAL:</b>
<form name="f1">
monkey:<input type="radio" name="r1" ><br>
DOG:<input type="radio" name="r1" ><br>
donkey:<input type="radio" name="r1"><br>
cat: <input type="radio" name="r1"><br><br>
<h2>Question2:</h2>
<h3> which of the following seems delicious to u:</h3>
crab:<input type="radio" name="r2" ><br>
snake:<input type="radio" name="r2" ><br>
dog:<input type="radio" name="r2"><br>
cockroach: <input type="radio" name="r2">
<br><br><br><br>
<center>
<input type="button" value="submit" name="b1" onclick="f11();">
</center>
</form>
<%@page import="java.sql.*" %>
<%
HttpSession s1= request.getSession();
Object o1=s1.getAttribute("Username");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String str=o1.toString();
Connection con= DriverManager.getConnection("jdbc:odbc:mydsn","hap py","happy");
Statement stmt= con.createStatement();
PreparedStatement pst= con.prepareStatement("update student set marks=? where name=?");
pst.setInt(1, result1);
pst.setString(2, str);
PreparedStatement ps1=con.prepareStatement("commit;");
</BODY>
</HTML>
- 06-14-2011, 09:55 AM #2
Member
- Join Date
- Jun 2011
- Posts
- 9
- Rep Power
- 0
pls do reply ASAP.
- 06-14-2011, 10:14 AM #3
"ASAP"
db
- 06-14-2011, 10:19 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
jvaScpt is to Jva as hm is to hmstr.
Am I doing it rght?
- 06-14-2011, 12:40 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
To summarise.
We're not here to do your bidding, so ASAP is simply rude.
Txt spk is a pain to read. Anything that makes it harder for us to read your post makes it harder for us to help you. The easier you make it for us the more likely you are to get help.
Finally, Javascript runs on the client. Java runs on the server.
- 06-15-2011, 05:31 PM #6
Member
- Join Date
- Jun 2011
- Posts
- 9
- Rep Power
- 0
i'm sorry to say ASAP .
bt i was to present it by 2day itself . so i thought of getting a quick help .
i didn't intend to be rude.
actually i m new 2 dis forum , so didn't knw how 2 attach files. so i just copied d code snippet.
thnks fr ur reply..
- 06-15-2011, 05:58 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Getting text from inside a jeditorpane inside a jtabbedpane
By captain alge in forum New To JavaReplies: 9Last Post: 04-12-2011, 07:26 PM -
ArrayLists do not print to the terminal window, why? long code inside
By caps_lock in forum New To JavaReplies: 5Last Post: 05-25-2009, 09:03 PM -
Running .java-files won't work/compile does!(Code inside)
By wyldstyle in forum New To JavaReplies: 6Last Post: 02-06-2009, 08:05 PM -
javascipt function is nt getting called
By pankaj_salwan in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-20-2008, 08:13 AM -
show a value in javascipt in the jsp page
By hussainzim in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05-20-2008, 09:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks