troubleshooting Question

Multiple forms

Avatar of ajt2915
ajt2915 asked on
JSP
4 Comments2 Solutions254 ViewsLast Modified:
I have two forms in one html and both needed to be posted to two different servlets.
<form name="mainFrm>
    <form name="form1>
      ...onClick="sub(0)"
    </form>
    <form name="form2>
      ...onClick="sub(1)"
    </form>
</form>
Following is the script I'm trying to execute from the onclick.
<Script language="javascript">
 function sub(i){
 document.mainFrm.method="post";
 document.mainFrm.action=go(i);
 document.mainFrm.submit();
}
function go(i){
var x,y;
if(i==0){x="abc"; y="/servlet1?id=" +x;}
if(i==1){x="123"; y="/servlet2?id=" +x;}
return y;
}
</script>

I'm having trouble posting the form.
ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros