Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

is this possible

i have a form, within that form, i have 3 button. I wish to submit the form to different action when user click on it... is it possible to let the javscript handle this?


<javascript>

function setActionA() {

document.test.action="ServletA";

}

function setActionB() {

document.test.action="ServletB";

}

</javascript>


<form name="testing" method="POST" >
..
..
<input type="button" value="gotoSevlet A " onClick="setActionA();" >
<input type="button" value="gotoSevlet B " onClick="setActionB();" >


What say you? If it's ridiculour, how should i make it happend?
0
poweranger77
Asked:
poweranger77
1 Solution
 
rrzCommented:
Here is one way.  But the back button doesn't  work.
<script>
function setActionA() {
                       location.replace("Setel.jsp");
}
function setActionB() {
                       location.replace("prain2.jsp");
}
</script>
<form name="testing" method="POST" >
<input type="button" value="gotoSevlet A " onClick="setActionA();" >
<input type="button" value="gotoSevlet B " onClick="setActionB();" >
</form>
0
 
rrzCommented:
<script>
function setActionA() {
                       location.replace("url of ServletA");
}
function setActionB() {
                       location.replace("url of ServletB");
}
</script>
<form name="testing" method="POST" >
<input type="button" value="gotoSevlet A " onClick="setActionA();" >
<input type="button" value="gotoSevlet B " onClick="setActionB();" >
</form>
0
 
radarshCommented:
Why are you struggling so much? Just do

<form name="testing" method="POST" >
<input type="button" value="gotoSevlet A " onClick="document.testing.action='ServletA';submit();" >
<input type="button" value="gotoSevlet B " onClick="document.testing.action='ServletB';submit();" >
</form>

________
radarsh
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
radarshCommented:
This is much like what you had posted but with the addition of a submit(); function
call.

________
radarsh
0
 
poweranger77Author Commented:
thank you
0
 
gespinolaCommented:
Simple, you can try this...

function setActionA() {

document.test.action="ServletA";
document.testing.submit();  //extra line
}

function setActionB() {

document.test.action="ServletB";
document.testing.submit();  //extra line
}

</javascript>


<form name="testing" method="POST" >
..
..
<input type="button" value="gotoSevlet A " onClick="setActionA();" >
<input type="button" value="gotoSevlet B " onClick="setActionB();" >
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now