Solved

HTML multiple form submit but as one single request

Posted on 2003-11-06
10
624 Views
Last Modified: 2010-04-09
What best I can do if I need to submit 2 forms at once but it has to go out as one single HTTP (post/get) request?
0
Comment
Question by:nik_c_shah
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 9695996
as one POST ... so that means you want to submit the data from two forms as if it were a single form?  If this is correct, then you can copy the fields from from2 into corresponding hidden fields in form1 and then submit form1.  Let me know if you need help with this.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9696000
"from2" should be "form2"
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9696028
combine both forms into one huge hidden master form

simple example

<html>
<body>
<form "aForm1">
<input type="text" name="num1" onkeyup="document.hiddenForm.num1.value = this.value">
</form>

<form "aForm2">
<input type="text" name="value1" onkeyup="document.hiddenForm.value1.value = this.value">
</form>

<button value="Submit" onclick="document.hiddenForm.submit()">

<form name="hiddenForm">
<input type="hidden" name="num1">
<input type="hidden" name="value1">
</form>
</body>
</html>
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9696030
oops sorry kEk
0
 

Author Comment

by:nik_c_shah
ID: 9696097
Since one of the forms is in an IFRAME element, can I not copy it as an object and nest it within the form I can submit ? And the forms have very large select boxes, i want to avoid parsing them and storing in arrays etc. Also how do u copy form elements (and not their contents into hidden fields)?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 33

Expert Comment

by:knightEknight
ID: 9696981
Bustarooms:  no worries at all.

Nik:  It would be helpful to see your code, but in general do this in the main page (the one containing the IFRame)


function copyIFrameFormElements()
{
    var iFrameForm = self.frames["nameOfTheIFrame"].document.forms["nameOfTheIForm"];
    var mainForm = document.forms["nameOfTheMainForm"];

    // if it is a text box:
    mainForm.hiddenField1.value = iFrameForm.textField1.value;

   // if it is a SELECT:
   mainForm.hiddenField2.value = iFrameForm.selectField2.options[iFrameForm.selectField2.selectedIndex].value;
}
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 400 total points
ID: 9699066
>>... copy it as an object and nest it within the form I can submit

the following demonstrates concatenating 2 forms in the same page.  You would simply have to modify one of the assignments to reflect your iframe -- frames.framename.document.getElementById('formID').innerHTML;

function doit(formObj)
{
  x = document.getElementById('b').innerHTML
  y = document.getElementById('a').innerHTML
  document.getElementById('a').innerHTML += x;
  z = document.getElementById('a').innerHTML
  alert(z)


}

//-->
</script>
</head>
<body>
<form name="a" onsubmit='doit(this)'>
<textarea name='theResults' id='theResults' rows=10 cols=40 onfocus=this.blur()>1
2
4
6
</textarea>
<input type="submit">
</form>
<form name='b' id='b'>
<input type="text" value='abc'>
</form>

Vinny
0
 

Author Comment

by:nik_c_shah
ID: 9699957
Guyz thanks for all ur insight. Vincent ur trick of adding up the innerHTML and submitting is really cool. I shall settle in for that. Is there an Netscape equivalent to it?
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9700992
Hi
  if you mean nn6+, it uses innnerHTML
  if you mean nn4.7, 99.9% percent sure don't think so.  NN4.7 layers are documents in and of themselves; so, while you would be able to access individual elements within the form with something like
 document.layers[divid].document.formname.elementname,
you would then have the problem of concatenating it into the 'submit' form. Also, the div would have to be positioned absolutely -- another potential problem.  You would be better off filling hidden fields.

Vinny
0
 

Author Comment

by:nik_c_shah
ID: 9721613
Further Update on error messages:

Exception loading servlet /nmsloader/test-tags.jsp stack:
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo: method (Ljava/lang/String;ZZLjava/lang/String;)V not found
      at org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:478)
      at org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:395)
      at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:350)
      at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:284)
      at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:696)
      at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:119)
      at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:190)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:1048)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:1022)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:1018)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:173)
      at com.netscape.server.http.servlet.NSServletEntity.load(NSServletEntity.java:230)
      at com.netscape.server.http.servlet.NSServletEntity.update(NSServletEntity.java:149)
      at com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:453)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SVG Logo 4 34
CSS measurement 10 34
html5 auto send email 7 22
bootstrap footer centering and columns alignement 3 22
Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now