...

View Full Version : Calling js functions from a frame



snaik
05-24-2004, 08:22 PM
Scenario:

Banner Frame
---------------------------
Left Frame | Right Frame
|
| Login Textbox
| Password Textbox
SUBMIT button



Code is as follows:



<!-- signpage1.jsp-->

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Mall Login Page</title>
</head>

<body>
<SCRIPT language="JavaScript">
function OnSubmitForm()
{
if(document.pressed == 'Login')
{
document.myform.action ="signpageprocess.jsp";
}

return true;
}
</script>


<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>Mall Admin Validation</b></p>
<table border="1" width="38%" bgcolor="#6699FF">
<tr>
<td width="100%">
<!--<form method="POST" action="confirmprocess.jsp">-->

<FORM name="myform" onSubmit="return OnSubmitForm();">

<p>&nbsp;Admin ID&nbsp;&nbsp;&nbsp; <input type="text" name="userid" size="20"></p>
<p>Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="userpass" size="20">
</p>
<p>&nbsp;</p>
<p><input type="submit" name ="Operation" onClick="document.pressed=this.value" value="Login" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>

</body>

</html>




signpageprocess.jsp

<%@ page contentType="text/html;charset=utf-8"
import="java.sql.*"
errorPage="error.jsp" %>

<html>
<head>
<title>Login Process</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
.normal { font-family: arial; font-size: x-small; font-style: normal; fontweight:
normal; text-decoration: none}
.normalbold { font-family: arial; font-size: x-small; font-style: normal;
font-weight: bold; text-decoration: none}
-->
</style>

</head>
<%

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:ReenaDB";
Connection confirmCon = DriverManager.getConnection(url, "", "");
String userid = request.getParameter("userid");
String userpass = request.getParameter("pass");
String jsql = "SELECT userid, userpass FROM userTable ";
jsql = jsql + "WHERE userid = ?";
PreparedStatement pstmt = null;
pstmt = confirmCon.prepareStatement(jsql);
pstmt.setString(1, userid);
ResultSet rs = pstmt.executeQuery();
%>

<body bgcolor="#FFFFFF">

<%
if( ! rs.next() )
{

%>
<table width="322" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#3399CC">
<td height="39" class="normalbold"><font color="#FFFFFF"
size="3">Your ID is incorrect!</font></td>
</tr>
<tr>
<td class="normal">
<p>Please verify your ID<br>
If you have not registered yet, please register first.</p>
<p align="center" class="normalbold">
<a href="2Userinput.jsp">Registration Page</a> </p>

</td>
</tr>
</table>
<%
}
else
{
// check password
if (userpass.trim().equals(rs.getString("userpass").trim()))
{
// put user into the session
session.setAttribute("userid", userid);
%>

<table width="322" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#3399CC">
<td height="39" class="normalbold"><font color="#FFFFFF"
size="3">Welcome!!!</font></td>
</tr>
<tr>
<td class="normal">
<p>Your logging process was successful...</p>
<a href = "Adminpage.jsp""> Admin Page</a></p>
</td>
</tr>
</table>

<%
}
else // Incorrect Password
{
%>
<table width="322" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#3399CC">
<td height="39" class="normalbold"><font color="#FFFFFF"
size="3">Loggin Failed!!</font></td>
</tr>
<tr>
<td class="normal">
<p>Incorrect Password<br>
Please check your password again!!</p>
</td>
</tr>
</table>

<%
}
}
%>

</body>
</html>





Problem is that on submit, the signpageprocess.jsp is called -- however the jsp script is not executed. Please help -- this is very urgent

A1ien51
05-24-2004, 08:39 PM
Please use code tags and disable smiles when you post here, then we can read the code easier!

Plus
JavaScript != JSP

do yourself a favor, on your jsp write out information to see if the script is being called. Find out if t the parameters are being passed. You might find out you need to specify post or get in the form.

Eric

immedicable
05-24-2004, 10:07 PM
that script has... many... problems... did you paste it out of word, or an editor? if it's urgent, maybe start over?

otherwise http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum