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

dohdohdohAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
code-colorsConnect With a Mentor Commented:
Hi,

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!
0
 
Om PrakashCommented:
Hi, try this
<%
  Dim formaction
  if Request.Form("shipping_country") ="AU") then 
  	formaction = "https://www.PayPal.com/cgi-bin/webscr" 
  else  
  	formaction = "checkout_success.asp" 
  end if
  %>
  
  <form 
  	name="checkout_PP_LI_Hid" 
  	action= <%=formaction%>
  	method="post">

Open in new window

0
 
theremonCommented:
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.
<html>
<head>
<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"; }
	else
		{ document.getElementById("chkForm").action="checkout_success.asp"; }
	}
</script>
</head>

<body>
<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>
</select>
<input type="submit" />
</body>
</html>

Open in new window

0
All Courses

From novice to tech pro — start learning today.