Shah
Shah

Reputation: 104

Assign action url dynamically to POST method

I've simple asp form in which I get few text fields, these values are stored in hidden fields. On button click I call post method as

<form method="post" action="https://test.mydomain.com/payment/AcceptRequestServlet"

this is working as desired. Now I got another requirement that based on a choice (captured through radio button) I should post to another url

e.g If option 1 then 
     <form method="post" action="https://test.mydomain.com/payment/AcceptRequestServlet1"
    If option 2 then
     <form method="post" action="https://test.mydomain.com/payment/AcceptRequestServlet2"

Is it possible to implement this.

Upvotes: 0

Views: 46

Answers (1)

Arindam Nayak
Arindam Nayak

Reputation: 7462

You can switch form action using javascript.

 if(case1)
  {
   document.myform.action ="https://test.mydomain.com/payment/AcceptRequestServlet1";
  }
  else

  {
    document.myform.action ="https://test.mydomain.com/payment/AcceptRequestServlet2";
  }

Assuming form is myform.

Upvotes: 1

Related Questions