easy way to do If value = x, then form action is "...", else form action is "..."

I need to change my form action based on the country value collected previously, but the way I have it doesn't work. I've also tried

if x then <form name=...action=...method=post> else <form name...
...whole lot of asp form actions....

but that didn't work either, both give expected statement error.

can anyone help me rewrite it so it doesn't complain?

<form name="checkout_PP_LI_Hid" action= <%if (NOT Request.Form("shipping_country")="AU") then "checkout_success.asp" else  "https://www.PayPal.com/cgi-bin/webscr" end if %> method="post">

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
Hi, try this
  Dim formaction
  if Request.Form("shipping_country") ="AU") then 
  	formaction = "https://www.PayPal.com/cgi-bin/webscr" 
  	formaction = "checkout_success.asp" 
  end if
  	action= <%=formaction%>

Open in new window

Hi there

do you want to do this before the form has been posted? If so, it need to be done using javascript. Check the following code. It changes the action value of the form depending on what you select in the dropdown.
If you want to do it depending on the value of a previously posted form, the reply of om_prakash_p should cover you.
<title>EE Test file - Question: 25491504 </title>
<script type="text/javascript">
function updFormPost(cnt)
	if (cnt=="AU")
		{ document.getElementById("chkForm").action="https://www.PayPal.com/cgi-bin/webscr"; }
		{ document.getElementById("chkForm").action="checkout_success.asp"; }

<form id="chkForm" name="checkout_PP_LI_Hid" action="checkout_success.asp" method="post">
<select size="1" name="country" onchange="updFormPost(options[selectedIndex].value)">
	<option value=""></option>
	<option value="AU">Australia</option>
	<option value="US">USA</option>
	<option value="UK">United Kingdom</option>
<input type="submit" />

Open in new window


You can use your same <form> tag with little modification,

<form name="checkout_PP_LI_Hid" action= "<%if (NOT Request.Form("shipping_country")="AU") then%>checkout_success.asp<%else%>https://www.PayPal.com/cgi-bin/webscr<%end if %>" method="post">

Try it!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.