0

I am extremely new to VB Script, and any help is extremely appreciated.

I currently have 4 images that need to be displayed based on the date. I have named each image as 1,2,3 and 4. I am using the date function to display this but I am getting a 500 error message. If there is a better way to accomplish this with VBScript please let me know. The images are in a folder specified in the path for the src inside the div and the extension of the images is PNG.

   <%@LANGUAGE="VBSCRIPT"%> 

<%
Dim CurDate

'CurDate = Month(DATE)
'CurDate =("2018-11-01")
 CurDate =(DATE)    

response.write(CurDate) 

If CurDate = "2018-10-30" THEN
    CurDate = 1
If CurDate = "2018-11-01" THEN
    CurDate = 2

If CurDate = "2018-11-02" THEN
    CurDate = 3

Else CureDate = 4

End If

%>  

     HTML Below


  <div style="padding-left:10px;text-align:center;">
    <img alt="Image- Displaying" border="0" src="http://Path/Default/Pane/imgFolder/<%=CurDate%>.png">
</div> 
user692942
  • 16,398
  • 7
  • 76
  • 175
Gestef
  • 128
  • 1
  • 8
  • Lankymart thank you for the comment but I am a little unsure. No, it's not a duplicate question. But for sure will use that post as a reference. Thank you a million. – Gestef Nov 01 '18 at 14:57
  • It definitely is, the problem is you are trying to compare dates but you are using the string representation of a date. – user692942 Nov 01 '18 at 18:51

1 Answers1

2

I think your problem is with your if/else/then.

<%@LANGUAGE="VBSCRIPT"%> 

<%
Dim CurDate

'CurDate = Month(DATE)
'CurDate =("2018-11-01")
 CurDate =(DATE)    

response.write(CurDate) 

If CurDate = "2018-10-30" THEN
    CurDate = 1
elseIf CurDate = "2018-11-01" THEN
    CurDate = 2
elseIf CurDate = "2018-11-02" THEN
    CurDate = 3
Else
    CurDate = 4
End If
%>  

     HTML Below


<div style="padding-left:10px;text-align:center;">
  <img alt="Image- Displaying" border="0" src="http://Path/Default/Pane/imgFolder/<%=CurDate%>.png">
</div> 
DanB
  • 2,022
  • 1
  • 12
  • 24
  • Yes, this was the main issue as you mentioned if/else/then statement .I am able to view the date and image now. At least I am able to pick it up from here. It is still not working to its fullest because everything gets defaulted to the Else statement. But I will pick it up from here. Thank you Very Much. – Gestef Nov 01 '18 at 15:29
  • Do if curdate = cdate("2018-10-30"), to compare date with date, instead comparing date with string. And, can you mark my answer a accepted? – DanB Nov 01 '18 at 16:15
  • No as you pointed out in the comments, the problem is comparing a date to a string which has already been pointed out as a duplicate question. – user692942 Nov 01 '18 at 18:53
  • 1
    The main issue (error 500) was not due to a date comparison. It was a syntax error. – DanB Nov 01 '18 at 18:54
  • Just reading the code I was able to know what was the error, even if the question was not enough detailled. There were many errors. A syntax error was more important since the script didn't work at all. – DanB Nov 01 '18 at 20:00