Solved

HTML multiple form submit but as one single request

Posted on 2003-11-06
10
622 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

707 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

21 Experts available now in Live!

Get 1:1 Help Now