General discussion

Locked

embedded html in visual basic if - then

By JayHouck ·
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.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

embedded html in visual basic if - then

by pVp In reply to embedded html in visual b ...

Actually, that sounds about right!

I think the HTML will render regardless.

You probably need to put the text in a <div> and change it from visible to invisible depending on the country, -or-
use doc.write("<text in question>") to put the text out or not.

Collapse -

embedded html in visual basic if - then

by JayHouck In reply to embedded html in visual b ...

Poster rated this answer

Collapse -

embedded html in visual basic if - then

by BebeZed In reply to embedded html in visual b ...

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

Collapse -

embedded html in visual basic if - then

by JayHouck In reply to embedded html in visual b ...

Poster rated this answer

Collapse -

embedded html in visual basic if - then

by anov In reply to embedded html in visual b ...

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

===== dropdn.asp ==========
<html><title> Drop down menu</title>
<body bgcolor=#ddffdd>

<%
country = request.querystring("country")
if country = "" then ' === first call, get form data
%>
<form>
<select name=country>
<option value=USA> UnitedStates of America</option>
<option value=Other> Outside continental USA</option>
</select><br>
<input type=submit value="Click here">
</form>
<%
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
%>

</body>
</html>

Collapse -

embedded html in visual basic if - then

by JayHouck In reply to embedded html in visual b ...

Poster rated this answer

Collapse -

embedded html in visual basic if - then

by JayHouck In reply to embedded html in visual b ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Software Forums