473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

two html forms

Hello Friends,
I have two forms(form1 and form2) on my html page.
question1 : can i access form 1 variables in form 2?. if so how?

question 2: when form2 action is saveci.jsp . can i access form1
variables in saveci.jsp. if so how?.

basically when form2 is submitted, form1 variables should be accessed
in the jsp which processes form2.

Thanks for the help!!!
s
Jul 17 '05 #1
1 2428
su**********@hotmail.com writes:
I have two forms(form1 and form2) on my html page.
question1 : can i access form 1 variables in form 2?. if so how?
In HTML there are no variables. In Javascript, you can access anything
on the page from anywhere else. So yes. Example of how:

<form id="form1"> ... <input name="foo" value="42">... </form>
<form id="form2"> ... <input name="bar">
<input type="button" value="copy"
onclick="this.form.elements['bar'].value =
document.forms['form1'].elements['foo'].value;">
...
</form>

question 2: when form2 action is saveci.jsp . can i access form1
variables in saveci.jsp. if so how?.
No. When submitting a form, only the named form controls of that
form is sent to the server.
basically when form2 is submitted, form1 variables should be accessed
in the jsp which processes form2.


Then you need to make it only one form. It is not that bad, you can
have different submit buttons to make people believe they send separate
forms:

<form id="megaform" action="saveci.jsp" method="post">
<fieldset><legend>What looks like form 1</legend>
...
<input type="submit" name="submit1" value="Submit Form 1">
</fieldset>
<fieldset><legend>What looks like form 2</legend>
...
<input type="submit" name="submit2" value="Submit Form 2">
</fieldset>
</form>

The name of the submit button that is used to submit the form is then
passed to the server along with the form data.

If you need the two forms to go to different pages, I suggest you
make an interface page that gets all the input, splits it as needed,
and switch to the real page. I don't know JSP, so I can't help you
with the details.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bob Nolty | last post by:
Hi all -- I'm trying to create a hidden form in the document using only Javascript -- I don't know what form I want until the user clicks a button -- I tried the following code, which does...
4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
6
by: William F. Zachmann | last post by:
We've got a project going that involves moving an old web site with a massive dll written in C++ that produces most of the output from a SQL 7.0 data base on NT4 onto IIS on Windows 2003 Server...
4
by: Sathyaish | last post by:
I am no JavaScript progammer, and unfortunately am having to babysit an old code base that has a lot of JavaScript in it. I have two questions: (1) Can two HTML controls have the same name? It...
5
by: nick | last post by:
I need to create a simple asp.net application that use password protect some html pages. The html page provider doesn't know asp.net. And the host doesn't allow me to create user accounts. ...
7
by: thersitz | last post by:
I can't seem to get my html form to submit properly from within a web form. Here's my form tag syntax and some delivery hidden fields. <form id="myForm"...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.