Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > two html forms

Reply
Thread Tools

two html forms

 
 
sumithradevi@hotmail.com
Guest
Posts: n/a
 
      10-29-2003
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
 
Reply With Quote
 
 
 
 
Jerry Park
Guest
Posts: n/a
 
      10-29-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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

If you saveci.jsp needs the information in both forms, why not use a
single form?

 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      10-29-2003
(E-Mail Removed) 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 - (E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to implement two drop-down list dependency in ASP/HTML/VBscript forms? srini HTML 7 08-30-2010 12:49 PM
How to compare two SOAP Envelope or two Document or two XML files GenxLogic Java 3 12-06-2006 08:41 PM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Having a Problem Trying to call two html iles to be loaded into two different frames Jofio Javascript 3 10-09-2005 09:50 AM
Creating ASP.NET forms, that act like HTML forms jlopes151 ASP .Net 2 03-14-2005 01:01 AM



Advertisments