Link to home
Start Free TrialLog in
Avatar of ajt2915
ajt2915

asked on

Multiple forms

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
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

"Delete/No refunds."
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Kuldeepchaturvedi
EE Cleanup Volunteer
I disagree with this one.  Both solutions would work.  Pts should goto objects.

CJ