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?

[Webinar] Streamline your web hosting managementRegister Today

code-colorsConnect With a Mentor Commented:

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!
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

All Courses

From novice to tech pro — start learning today.