Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calling js functions from a frame

    Scenario:
    Code:
                      Banner Frame
       ---------------------------
        Left Frame        | Right Frame
                              |      
                              |                 Login      Textbox
                              |                 Password Textbox 
                                                        SUBMIT button


    Code is as follows:
    Code:
    <!-- 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
    Last edited by liorean; 05-24-2004 at 08:50 PM. Reason: codified and desmilied

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Registered User
    Join Date
    Apr 2004
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/jst...ocs/index.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •