Access a javascript variable inside a JSP block?
Im creating a cms page, and what i want to do is to delete from my database(on button click) all userid that are checked in the list of userid
<%
//registering the driver
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
//defining URL of database server
String url ="jdbc:mysql://localhost:3306/database";
String uname ="jayson";
String pswd ="jayson";
//getting the connection
Connection connect = DriverManager.getConnection(url, uname, pswd);
%>
<script type="text/JavaScript">
function jsDELETE(){
for (var i=0; i < document.form1.checkpending.length; i++)
{
if (document.form1.checkpending[i].checked)
{
<%
Statement stmnt;
stmnt = connect.createStatement();
//i am getting the error here
String sq ="DELETE FROM credentials where UserId = " + document.form1.checkpending[i].value;
stmnt.executeUpdate(sq);
%>
}
}
}
//-->
</script>
i am trying to append checked values(document.form1.checkpending.value ) to my sql statement but i am getting an error.
Is there a better way to do these?
thanks in advance. =)

