Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet multiple form with multiple function in 1 jsp

Have Programming Question? Ask it here!
 
 
 


anson
multiple form with multiple function in 1 jsp
2 Answer(s)      4 years and 5 months ago
Posted in : JSP-Servlet


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>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="nameCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Your password: </td>
<td>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="emailCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Contact number: </td>
<td>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="contactCustomer" maxlength="11" /></td>
</tr>
<tr>
<td>Address: </td>
<td>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="40" name="addressCustomer" maxlength="45" /></td>
</tr>
<tr>
<td>NRIC: </td>
<td>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="NRICCustomer" maxlength="14" /></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="button" class="buttons" value="Clear" onclick="clear()"/></td>
<td>&nbsp;&nbsp;</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>

Advertisement
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>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="nameCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Your password: </td>
<td>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="emailCustomer" maxlength="30" /></td>
</tr>
<tr>
<td>Contact number: </td>
<td>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="contactCustomer" maxlength="11" /></td>
</tr>
<tr>
<td>Address: </td>
<td>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="40" name="addressCustomer" maxlength="45" /></td>
</tr>
<tr>
<td>NRIC: </td>
<td>&nbsp;&nbsp;</td>
<td><input type="text" SIZE="20" name="NRICCustomer" maxlength="14" /></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="reset" class="buttons" value="Clear" /></td>
<td>&nbsp;&nbsp;</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-Servlet
multiple 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
multiple submits, single form.
multiple submits, single form.  is it possible to use multiple submit buttons in a single form?   Thank you
Advertisements
Multiple form in Jsp
Multiple form in Jsp       In this section, we have developed an Multiple form...;userform.jsp") to create the multiple form. <!DOCTYPE HTML PUBLIC
send multiple textbox vaues in to an jsp form to store them in a DB table
send multiple textbox vaues in to an jsp form to store them in a DB table  Hi sir... I am not getting how can i send the multiple input text box values in to an jsp file with additional values to store those values
Handling multiple buttons in HTML Form
Handling multiple buttons in HTML Form  How to handle Handling multiple buttons in HTML Form
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  ... a .jsp( say abc.jsp) file which contains multiple Action form.I am required to add one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
Multiple forms in JSP - JSP-Servlet
Multiple 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-Servlet
Multiple 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
Round of to a multiple of 5 without using function
Round 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 function
Round 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
Email to multiple recipients using jsp
Email 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 jsp
Email 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
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
update multiple rows in jsp - JSP-Servlet
update 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
Multiple file Uploading - JSP-Servlet
Multiple 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
How to display multiple images in jsp
How 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
Uploading multiple files in JSP - JSP-Servlet
Uploading 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
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
Multiple submit buttons in single xhtml form - Java Server Faces Questions
Multiple submit buttons in single xhtml form  Hi all, Here I am attaching the source of the page , which containig two submit buttons. Somebody suggested to keep eaxh button in different form. I am new to JSF, can anyone split
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
JSP WITH MULTIPLE FORMS
JSP WITH MULTIPLE FORMS     ... in single jsp page. Most of the times people need to use multiple forms... clicked on the button (labeled by "Form 1"), you will see the data of Form1
multiple browsers in java script - JSP-Servlet
multiple 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
how to send mail with multiple attachments in jsp
how to send mail with multiple attachments in jsp  how to send mail with multiple attachments in java script
get value from multiple textbox in jsp
get 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">
Multiple submit nuttons in single xhtml form - Java Server Faces Questions
Multiple submit nuttons in single xhtml form  Hi, I am facing problem in my JSF application, where in single page , we have two submit buttons. If any one of the button is clicked , then entire form is submitted. How to avoid
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi, java does not support multiple inheritance
problem of static in jsp page by multiple user access
problem 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
mail with multiple attachments
mail with multiple attachments  code for sending mail with multiple attachments in jsp
multiple dropdowns in single page - JSP-Servlet
multiple dropdowns in single page  i have a jsp page having drop down... the below servlet my jsp Untitled Document...(); adminpendrequestList.add(rs.getString(1
java multiple users with single connection - JSP-Servlet
java multiple users with single connection  hi, my problem... it for multiple users who uses a single connection to the database simultaneously... of the above websites uses a single connection with multiple users. n
multiple inheritance
multiple 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 inheritance
multiple 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 Inheritance
Multiple 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 Inheritance
Multiple 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
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database and the file in folder  how to upload multiple files in jsp and saving the path in database and the file in folder I have created a form for the upload of files
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
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp...; <html:form action ="/college.do"> <fieldset> <legend>...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
multiple inhertence
multiple inhertence  package start; class A { protected void a() //a method in A { System.out.println("Class A"); } } class B extends A { public B() { super
multiple inhertence
multiple inhertence  package start; class A { protected void a() //a method in A { System.out.println("Class A"); } } class B extends A { public B() { super
Multiple select box
"; } } function remove(){ form.text.value=""; } </script> <form name="form...Multiple select box  Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection
Add multiple UIBarButtonItem
Add multiple UIBarButtonItem  add multiple uibarbuttonitem
Advertisements
 

 

 

DMCA.com