Discussion Locked

embedded html in visual basic if - then

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hey everyone,

I am working on an asp with lots of problems. Here's a big one... I want to limit orders from outside the US. The customer has chosen a country from a drop down menu containing USA and Other.

<% if country=Other then %>
Your order could not be completed. We do not ship outside the continental United States at this time.

<% else %>

The problem is that regardless of the country, the statement prints. It is like the statement is not part of the if - then. I have tried moving the %> to include everything, that doesn't work... Let me know any thoughts. I have been thrown into the position of fixing someone else's site (they quit) and I am overwhelmed with the switching between html, asp, visual basic, java,etc. Thanks.

7 replies

by pvp

Actually, that sounds about right!

I think the HTML will render regardless.

You probably need to put the text in a

and change it from visible to invisible depending on the country, -or-
use doc.write("") to put the text out or not.

by bebezed

Is Other a variable? If not, then you will need to put the word Other in quotes:

<% If country="Other" then %>

If you don't put it in quotes, it is assumed to be a variable.

Also, if this comes from a form and you haven't set the country variable, this will also cause problems... make sure the following line is somewhere above the IF statement:

<% country=request.form("country") %>

HTH...

by anov

The problem is caused by lack of quotation. The IF statement should read
<% if country="Other" then %>
The reason might also be in tag, where "Value" attribute should be explicitely defined. Working example follows.

===== dropdn.asp ==========
Drop down menu

<%
country = request.querystring("country")
if country = "" then ' === first call, get form data
%>

<%
else ' === second call, process data received
if country = "Other" then
%>
Do not ship outside continental USA
<%
else
%>
The prodict will be shipped to you shortly
<%
end if
end if
%>

This discussion is closed to new replies.