ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 30th, 2009, 04:49 PM
iomr iomr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 iomr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 5 sec
Reputation Power: 0
ASP If Then Statement Question

I'm trying to get this If Then Statement to work:

Code:
Dim Movie_Link_Statement

If Movie_Link = "DNE" Then
Movie_Link_Statement="<li>asdf</li>"
Else
Movie_Link_Statement="<li><a href=""" & Movie_Link & """>Watch the " & Product_Name & "Movie</a></li>"
End If


Basically, the variable Movie_Link has been retrieved from a database. If there is a Movie_Link, it is in the form of a regular web address; if not, it is entered into the database as "DNE" (does not exist). If there is a link, the variable Movie_Link_Statement will display the properly formatted link in the html of my page; if not, there will be nothing displayed. In theory, it would work fine, but for some reason, the if statement is ignored, and only the else statement is applied. Any ideas?

Reply With Quote
  #2  
Old June 30th, 2009, 05:22 PM
banksie banksie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2007
Location: Crowle, Worcester
Posts: 21 banksie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 1 m 23 sec
Reputation Power: 0
I think this might work!

Code:
If Movie_Link = "DNE" Then
Movie_Link_Statement="<li>asdf</li>"
Else
Movie_Link_Statement="<li><a href='" & Movie_Link & "'>Watch the " & Product_Name & " Movie</a></li>"
End If


I hope this works!

Reply With Quote
  #3  
Old June 30th, 2009, 05:32 PM
mystic7's Avatar
mystic7 mystic7 is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2006
Posts: 1,480 mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level)mystic7 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 11 h 7 m 17 sec
Reputation Power: 270
If Banksie's solution doesn't work, try this. I sometimes find that when an If/Then statement doesn't work the way it should, reversing it usually does the trick.

Code:
If Movie_Link <> "DNE" Then
Movie_Link_Statement="<li><a href='" & Movie_Link & "'>Watch the " & Product_Name & " Movie</a></li>"
Else
Movie_Link_Statement="<li>asdf</li>"
End If

Reply With Quote
  #4  
Old July 1st, 2009, 12:22 AM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 1,530 keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 49 m 10 sec
Reputation Power: 825
Send a message via Yahoo to keep_it_simple
syntactically your url is good...unless you want to change to banksie example for whatever reason...


have you actually checked the value of the variable Movie_Link? (Debug)...as you may have guessed, it has to be literally a capitalized DPE...no variations of unless you use UCase...yo can also apply a quick debugging technique by hard coding the values - to make sure your actual logic is correct

Code:
<%
' replace w/ your table/field names
  Movie_Link = oRs("Movie_Link") 
  Product_Name = oRs("Product_Name")

  ' debug
  Response.write "The value of 'Movie_Link' variable is: " & Movie_Link 
  Response.End

  If Movie_Link = "DNE" Then
   Movie_Link_Statement="<li>asdf</li>"
  Else
   Movie_Link_Statement="<li><a href=""" & Movie_Link & """>Watch the " & Product_Name & "Movie</a></li>"
  End If

  response.write Movie_Link_Statement
%>
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon

Reply With Quote
  #5  
Old July 2nd, 2009, 09:40 AM
iomr iomr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 iomr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 5 sec
Reputation Power: 0
Hmm, thanks for the suggestions, but they don't seem to be helping. I tried to isolate the problem by removing the link if Product_Link = anything but DNE and simplifying the code.

asp Code:
Original - asp Code
  1. Dim Movie_Link_Statement
  2.  
  3. If Movie_Link = "DNE" Then
  4. 'Movie_Link_Statement="<li><a href='" & Movie_Link & "'>Watch the " & Product_Name & " Movie</a></li>"
  5. Movie_Link_Statement="<li>This Doesn't Exist</li>"
  6. Else
  7. Movie_Link_Statement="<li>This Does Exist</li>"
  8. End If
  9. %>
  10. <%=Movie_Link%>
  11. <%=Movie_Link_Statement%>


When I set Movie_Link to "DNE" (exactly, all caps), the output is:

DNE
This Does Exist

When I set the Movie_Link to "googlec.om", the output is:

googlec.om
This Does Exist

Any ideas?

Reply With Quote
  #6  
Old July 2nd, 2009, 09:56 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Post

Did you debug as per K_I_S's example?

I must admit that I disagree with the suggestion of reversing the If/End If because it means that everything by default will Exist if it doesnt equal DNE, which is not what you want.

Try using CStr and Trim:
Code:
Dim Movie_Link_Statement

If Trim(UCase(CStr(Movie_Link))) = "DNE" Then
Movie_Link_Statement="<li>asdf</li>"
Else
Movie_Link_Statement="<li><a href=""" & Movie_Link & """>Watch the " & Product_Name & "Movie</a></li>"
End If
Comments on this post
iomr agrees: Thanks so much!

Reply With Quote
  #7  
Old July 2nd, 2009, 10:01 AM
iomr iomr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 7 iomr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 5 sec
Reputation Power: 0
Thank you so much, adding the CStr and Trim made it work like a charm!

Reply With Quote
  #8  
Old July 2nd, 2009, 10:04 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Quote:
Originally Posted by iomr
Thank you so much, adding the CStr and Trim made it work like a charm!

You're welcome, glad it helped!!!
Comments on this post
keep_it_simple agrees!

Reply With Quote
  #9  
Old July 2nd, 2009, 11:28 PM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 1,530 keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level)keep_it_simple User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 49 m 10 sec
Reputation Power: 825
Send a message via Yahoo to keep_it_simple
...sounds like it's a manually entered value from a form then inserted into a database... if this is the case then you should check values BEFORE you insert into the database...(client side and/or server side validation) - this would have more than likely prevented this problem


good call sos
Comments on this post
sync_or_swim agrees: I agree. Prevention as opposed to cure!!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > ASP If Then Statement Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT