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

 
 


anson
multiple form with multiple function in 1 jsp
2 Answer(s)      3 years and a month 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>
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 Pages:
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 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
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
multiple dropdown issue
multiple dropdown issue  This is Venkat from Hyderabad,India.Working... valuable suggestions.. Technologies I used are Java, J2ee, jsp,Servlets, Javascript... is overriding the previous one... I'm having requirement like multiple
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 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 select dropdown with Ajax
Multiple select dropdown with Ajax This tutorial explains how to create multiple select  dropdown with Ajax  in JSP and Servlet . This example...=allseleted.substring(1); getSubCategory(allseleted); } function
multiple submits, single form.
multiple submits, single form.  is it possible to use multiple submit buttons in a single form?   Thank you
Retriving multiple values of checkboxes in struts
Retriving multiple values of checkboxes in struts  how to retrive multiple values of checkboxes of jsp in action class   JSP Retrieve checkbox values 1)checkbox.jsp: <html> <body> <form method="post
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
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
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
Multiple file upload - Struts
: In jsp use : enctype="multipart/form-data" method="post...Multiple file upload  HI all, I m trying to upload multiple files using struts and jsp. I m using enctype="multipart". and the number of files
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
J2ME handing multiple pages
J2ME handing multiple pages  I have 1 midlet and 1 form. How do i make my display of the midlet when users pressed the back command from the form... implements CommandListener { private newUser Login; private Form form; private Display
Uploading Multiple Image On Server?
;Struts 2 upload multiple files example</h1> <s:form action="resultAction...Uploading Multiple Image On Server?  Hello sir, I am stuck with a problem of uploading multiple images on server. i have done a code which works
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
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
Dynamic include of multiple files
Dynamic include of multiple files  I want to include a series...; fileArray.length; i++) { String fn = "./" + fileArray[i] + ".inc.jsp"; %><jsp: include...; This works perfectly. However, what I need is to be able to (1) make
Multiple Forms in JSP
Multiple Forms in JSP          The form tag creates a form for user input. A form... of the form tag. For the browser it is important to know where to send
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
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
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
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
Java Multiple Insert Query
example that demonstrates how to execute the multiple sql insert query in JSP... the multiple selected items from the dropdown list into the JSP page I have use... and submission of form. JSP Code getValueIntoDropdownList.jsp <%@ page language
mail with multiple attachments
mail with multiple attachments  code for sending mail with multiple attachments in jsp
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using... fields bookid,author and title in the database. 1) Create book.jsp <%@page import="java.sql.*"%> <form name=myname method=post action="delete.jsp">
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 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
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
Uploading the multiple files
. Define form action equal to "multiple_upload_ac.php", method equal...;#CCCCCC"> <tr> <form action="multiple_upload_ac.php"...Multiple File uploading This script uploads the multiple file at a time
disable the form - JSP-Servlet
Multiple form are created in Jsp. Servlet is used to insert the data. Ajax is used... are different.when I click the form button,one function is calling and the input... Ajax. after response is coming to the jsp page,particular form button
query regarding multiple select
query regarding multiple select  i have a select in jsp with multiple options.When i select multiple values i am not able to insert it into database and how do i retrieve them..please help me with an example code
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 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
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 implementaion of datepicker.
Multiple implementaion of datepicker.  Hello Sir I am using date-picker in my web page. But i need to put date-picker on multiple text fields...="EndDate" class="calendar" /> Then, in your document.ready function
Upload and Download multiple files
Upload and Download multiple files  Hello Sir/Madam, I need a simple code for upload and download multiple files(it may be image,doc... using jsp with sqlserver ,can you please provide a proper coding for it and also

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.