multiple form with multiple function in 1 jsp
Hi, I'm using Netbean 6.8, mysql, and tomcat for my web application.
I was having problem in triggering my jsp with 2 forms as 1 for registration and 1 for log in. I need to trigger each form to call several function when user click buttons of these forms. Eventhough i put these forms into 1 form, i still can run my registration part, but my log in form is working.
not sure what is the problem i faced here. Here is my code:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Home Page</title>
<script language="JavaScript" type="text/javascript">
javascript:window.history.forward(1);
if (window != top) {
top.location.href="signup.jsp"
}
function clear() {
alert("CLEAR1 ??");
alert("CLEAR ??");
document.nameCustomer.value.clear();
document.pwdCustomer.value="";
document.emailCustomer.value="";
document.contactCustomer.value="";
document.addressCustomer.value="";
document.NRICCustomer.value="";
}
function login() {
var f = document.signup;
var length;
var userID = f.UserID.value;
var userPwd = f.UserPwd.value;
length = userID.length;
if (length < 1) {
alert("User ID is null. Please key in User ID.");
f.UserID.focus();
return(false);
}
length = userPwd.length;
if (length < 1) {
alert("Password is null. Please key in Password.");
f.UserPwd.focus();
return(false);
}
//alert(userPwd.valueOf());
//alert(userID.valueOf());
f.method = "POST";
//alert("going in servletLogin");
f.action = "servletLogin";
f.submit();
}
function checkEnterKey() {
var keyValue;
keyValue = window.event.keyCode;
if (keyValue == 13) {
login();
}
}
</script>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="./css/style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<form name="signup">
<div id="logo">
<h1><a href="index.jsp">Online Furniture House </a></h1>
<p><em>Welcome to Furniture House</em></p>
</div>
<hr />
<!-- end #logo -->
<div id="header">
<div id="menu">
<ul>
<li><a href="index.jsp" class="first">Home</a></li>
<li><a href="livingroom.jsp">Living Room</a></li>
<li><a href="kitchen.jsp">Kitchen</a></li>
<li><a href="bedroom.jsp">Bed Room</a></li>
<li><a href="office.jsp">Office</a></li>
</ul>
</div>
<!-- end #menu -->
<div id="search">
<form method="get" action="">
<fieldset>
<input type="text" name="s" id="search-text" size="15" />
<input type="submit" id="search-submit" value="Search" />
</fieldset>
</form>
</div>
<!-- end #search -->
</div>
<!-- end #header -->
<!-- end #header-wrapper -->
<div id="page">
<div id="content">
<div class="post">
<h2 class="title">Sign Up to Furniture House</h2>
<div class="entry">
<table border="0">
<tr>
<td colspan="3"><b>Log in information</b></td>
</tr>
<tr>
<td>Your name: </td>
<td> </td>
<td><input type="text" SIZE="20" name="nameCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Your password: </td>
<td> </td>
<td><input type="text" SIZE="20" name="pwdCustomer" maxlength="20" /></td>
</tr>
</table>
<div style="margin:30px 0px 30px 0px;"></div>
<table>
<tr>
<td colspan="3"><b>Personal information</b></td>
</tr>
<tr>
<td>Gender: </td>
<td> </td>
<td><input type="radio" name="genderCustomer" value="male" />Male<input type="radio" name="genderCustomer" value="female" />Female</td>
</tr>
<tr>
<td>Email address: </td>
<td> </td>
<td><input type="text" SIZE="20" name="emailCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Contact number: </td>
<td> </td>
<td><input type="text" SIZE="20" name="contactCustomer" maxlength="11" /></td>
</tr>
<tr>
<td>Address: </td>
<td> </td>
<td><input type="text" SIZE="40" name="addressCustomer" maxlength="45" /></td>
</tr>
<tr>
<td>NRIC: </td>
<td> </td>
<td><input type="text" SIZE="20" name="NRICCustomer" maxlength="14" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><input type="button" class="buttons" value="Clear" onclick="clear()"/></td>
<td> </td>
<td><input type="button" class="buttons" value="Submit" onclick="signup()"/></td>
</tr>
</table>
</div>
</div>
</div><!-- end #content -->
<div id="sidebar">
<ul class="post">
<li>
<h2 class="entry">Log In</h2>
<TABLE>
<TR>
<TD><p>Username: </p></TD>
<TD><input type="text" SIZE="20" name="UserID" maxlength="30" onkeypress="checkEnterKey();" /></TD>
</TR>
<TR>
<TD><p>Password: </p></TD>
<TD><input type="password" SIZE="20" name="UserPwd" maxlength="20" onkeypress="checkEnterKey();"/></TD>
</TR>
</TABLE>
<input type="button" class="buttons" value="Login" onclick="login()"/>
<p>Forget your password ? <a href="forgetpassword.jsp"> Click here</a></p>
<p>Not member yet ? <a href="signup.jsp"> Join now</a></p>
</li>
</ul>
</div>
</html>
View Answers
April 19, 2010 at 5:19 PM
Hi Friend,
Try the following code:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Home Page</title>
<script language="JavaScript" type="text/javascript">
javascript:window.history.forward(1);
if (window != top) {
top.location.href="signup.jsp"
}
function signUP(){
var v1=document.customer.nameCustomer.value;
var v2=document.customer.pwdCustomer.value;
var v3=document.customer.emailCustomer.value;
var v4=document.customer.contactCustomer.value;
var v5=document.customer.addressCustomer.value;
var v6=document.customer.NRICCustomer.value;
window.open("insert.jsp?name="+v1+"&&pass="+v2+"&&email="+v3+"&&contact="+v4+"&&address="+v5+"&&nric="+v6);
}
function login() {
var f = document.signup;
var length;
var userID = f.UserID.value;
var userPwd = f.UserPwd.value;
length = userID.length;
if (length < 1) {
alert("User ID is null. Please key in User ID.");
f.UserID.focus();
return(false);
}
length = userPwd.length;
if (length < 1) {
alert("Password is null. Please key in Password.");
f.UserPwd.focus();
return(false);
}
f.method = "POST";
f.action = "../servletLogin?user="+userID+"&&pass="+userPwd;
f.submit();
}
function checkEnterKey() {
var keyValue;
keyValue = window.event.keyCode;
if (keyValue == 13) {
login();
}
}
</script>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="./css/style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="logo">
<h1><a href="index.jsp">Online Furniture House </a></h1>
<p><em>Welcome to Furniture House</em></p>
</div>
<hr />
<!-- end #logo -->
<div id="header">
<div id="menu">
<ul>
<li><a href="index.jsp" class="first">Home</a></li>
<li><a href="livingroom.jsp">Living Room</a></li>
<li><a href="kitchen.jsp">Kitchen</a></li>
<li><a href="bedroom.jsp">Bed Room</a></li>
<li><a href="office.jsp">Office</a></li>
</ul>
</div>
<div id="search">
<form name="method="get" action="">
<fieldset>
<input type="text" name="s" id="search-text" size="15" />
<input type="submit" id="search-submit" value="Search" />
</fieldset>
</form>
</div>
</div>
<div id="page">
<div id="content">
<div class="post">
<h2 class="title">Sign Up to Furniture House</h2>
<div class="entry">
April 19, 2010 at 5:20 PM
continue..
<form name="customer" >
<table border="0">
<tr>
<td colspan="3"><b>Log in information</b></td>
</tr>
<tr>
<td>Your name: </td>
<td> </td>
<td><input type="text" SIZE="20" name="nameCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Your password: </td>
<td> </td>
<td><input type="password" SIZE="20" name="pwdCustomer" maxlength="20" /></td>
</tr>
</table>
<div style="margin:30px 0px 30px 0px;"></div>
<table>
<tr>
<td colspan="3"><b>Personal information</b></td>
</tr>
<tr>
<td>Gender: </td>
<td> </td>
<td><input type="radio" name="genderCustomer" value="male" />Male<input type="radio" name="genderCustomer" value="female" />Female</td>
</tr>
<tr>
<td>Email address: </td>
<td> </td>
<td><input type="text" SIZE="20" name="emailCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Contact number: </td>
<td> </td>
<td><input type="text" SIZE="20" name="contactCustomer" maxlength="11" /></td>
</tr>
<tr>
<td>Address: </td>
<td> </td>
<td><input type="text" SIZE="40" name="addressCustomer" maxlength="45" /></td>
</tr>
<tr>
<td>NRIC: </td>
<td> </td>
<td><input type="text" SIZE="20" name="NRICCustomer" maxlength="14" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><input type="reset" class="buttons" value="Clear" /></td>
<td> </td>
<td><input type="button" class="buttons" value="Submit" onclick="signUP()"/></td>
</tr>
</table>
</form>
</div>
</div>
</div><!-- end #content -->
<div id="sidebar">
<ul class="post">
<li>
<h2 class="entry">Log In</h2>
<form name="signup">
<TABLE>
<TR>
<TD><p>Username: </p></TD>
<TD><input type="text" SIZE="20" name="UserID" maxlength="30" onkeypress="checkEnterKey();" /></TD>
</TR>
<TR>
<TD><p>Password: </p></TD>
<TD><input type="password" SIZE="20" name="UserPwd" maxlength="20" onkeypress="checkEnterKey();"/></TD>
</TR>
<TR><TD><input type="button" class="buttons" value="Login" onclick="return login()"/></TD></TR>
</TABLE>
</form>
<p>Forget your password ? <a href="forgetpassword.jsp"> Click here</a></p>
<p>Not member yet ? <a href="signup.jsp"> Join now</a></p>
</li>
</ul>
</div>
</div>
</html>
Thanks
Related Tutorials/Questions & Answers:
multiple form with multiple function in 1 jsp - JSP-Servletmultiple form with
multiple function in
1 jsp Hi, I'm using Netbean... in triggering my
jsp with 2 forms as
1 for registration and
1 for log in. I need to trigger each
form to call several
function when user click buttons of these forms
Advertisements
Multiple form in Jsp
Multiple form in
Jsp
In this section, we have developed an
Multiple form... a web page ("userform.jsp") to
create the
multiple form.
<
Multiple forms in JSP - JSP-ServletMultiple forms in JSP
Hi,
I want to place
multiple submit buttons in
jsp pages ! and the
multiple buttons will perform
multiple actions based on the click of those buttons !
function Multiple upload - JSP-ServletMultiple upload Hello everyone and Deepak
i am using
jsp and mysql
I am using the program published on roseindia.net of
Multiple upload and i am facing an error as given below please help and reply soon this is my 8th
How to pass multiple values from a servlet to JSP?How to pass
multiple values from a servlet to
JSP? hi, I want to pass
multiple values
form a servlet to
JSP.
Hw do i do that?
I am able to send one value at a time without any prb, but I am unable to carry
multiple (from two
Email to multiple recipients using jspEmail to
multiple recipients using jsp Hi sir,
Am a doing a project,in that i need to send email to
multiple user at a time,the to address should enter manually its not not be written in code using
jsp.
Regards,
Santhosh
Email to multiple recipients using jspEmail to
multiple recipients using jsp Hi sir,
Am a doing a project,in that i need to send email to
multiple user at a time,the to address should enter manually its not not be written in code using
jsp.
Regards,
Santhosh
update multiple rows in jsp - JSP-Servletupdate
multiple rows in jsp Hi I am trying to do a
multiple row update in
JSP.
code as follows..
>
Can you please tell me how to get this
form values in actio page Hi Friend
Round of to a multiple of 5 without using functionRound of to a
multiple of 5 without using function Please help me out...
U enter values like 239, 2543.876, 962....
Give me an equation without using any
function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using functionRound of to a
multiple of 5 without using function Please help me out...
U enter values like 239, 2543.876, 962....
Give me an equation without using any
function which will give output of 240, 2545, 960 respectively
Multiple image upload using JSPMultiple image upload using JSP I have written a code to upload the
multiple images using
jsp, but when I execute this code, it throws Corrupt
form...="text/html; charset=utf-8" />
<
FORM action="upload_jsp.jsp" enctype
Multiple file Uploading - JSP-ServletMultiple file Uploading Hello everyone
I am using
jsp and my IDE is eclipse and back end is ms sql server
i am trying to upload
multiple... Submission
Claim Submission
Claim
Form Uploading Multiple Files Using Jsp Uploading
Multiple Files Using
Jsp
... to understand how you can upload
multiple files by using the
Jsp.
We should avoid to use
Jsp for performing any logic, as
Jsp is mainly used for the presentation
Uploading multiple files in JSP - JSP-ServletUploading
multiple files in JSP Hi,
I have this code in
JSP for Uploading
multiple files :
Samples : Simple Upload... :
Attach another File
var upload_number = 2;
var test="null";
function How to carry multiple values from a Servlet to a JSP?How to carry
multiple values from a Servlet to a
JSP? By using the below code I am able to carry the username to a
JSP (single value).
----response.sendRedirect("index.jsp?uname="+username);----
But I want
multiple values
How to display multiple images in jspHow to display
multiple images in jsp <%@ page import="java.io....;();
while(rs.next()) {
System.out.println("st-1");
bl.add(rs.getBlob(
1...="+rs1.getInt(
1));
for(int i=0;i<bl.size();i++){
System.out.println("st-3
multiple browsers in java script - JSP-Servletmultiple browsers in java script How to make my
jsp browser specific? Hi friend,
For solving the problem visit to :
http://www.roseindia.net/
jsp/simple-
jsp-example/JSPPlugins.shtml
Thanks
JSP WITH MULTIPLE FORMS
JSP WITH
MULTIPLE FORMS
... in single
jsp page. Most of the times people need to use
multiple forms.... Suppose if you clicked on the button (labeled by "
Form 1"),
you will see
get value from multiple textbox in jspget value from
multiple textbox in jsp how to get
multiple textbox value in another
jsp?
If i using the following code
<%for(int i=0;i<3;i++)
{%>
<td>name<input type="text" class="name" id="name">
problem of static in jsp page by multiple user accessproblem of static in
jsp page by
multiple user access hi ,
i am continuing my online exam project,but i have a Singleton class which i am invoking from my
jsp page , ths page can access by more number of users .every user
multiple inheritance.multiple inheritance. hello,
can java support
multiple inheritance???
hi,ADS_TO_REPLACE_1
java does not support
multiple inheritance
JSP edit multiple rows JSP edit
multiple rows
In this tutorial, you will learn how to update
multiple records at the same
time. The given example retrieves the record from... and allow the user to edit that
particular record. User can edit
multiple rows from
multiple inheritancemultiple inheritance Class A extends Class B but Class A also inherit Super Class Object so it is
multiple inheritence give reason in support of your answer
multiple inheritancemultiple inheritance why java doesn't support
multiple inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
Multiple InheritanceMultiple Inheritance Why Java Doesn't have
Multiple Inheritance It is Advantage or Disadvantage.........
Hi Friend,
When we extends... and inconsistencies Java does not support
Multiple Inheritance.
Thanks
Multiple InheritanceMultiple Inheritance All are saying java doesn't support
multiple inheritance but by default Object class is super class for all the user defined... class so java any how do
multiple inheritance? Can you please explain