IF Statement wrong?

garethtnash
garethtnash used Ask the Experts™
on
My HTML editor is telling me that this is the wrong way of doing this -

<%IF RsProductDetail.Fields.Item("Image2") <> "" then %><body onload="MM_preloadImages('<%=(RsProductDetail.Fields.Item("MainImage").Value)%>','<%=(RsProductDetail.Fields.Item("Image2").Value)%><%IF RsProductDetail.Fields.Item("Image3") <> "" then %>,'<%=(RsProductDetail.Fields.Item("Image3").Value)%><%End if%><%IF RsProductDetail.Fields.Item("Image4") <> "" then %>,'<%=(RsProductDetail.Fields.Item("Image4").Value)%><%End if%><%IF RsProductDetail.Fields.Item("Image5") <> "" then %>,'<%=(RsProductDetail.Fields.Item("Image5").Value)%><%End if%><%IF RsProductDetail.Fields.Item("Image6") <> "" then %>,'<%=(RsProductDetail.Fields.Item("Image6").Value)%>')"><%Else%><Body><%End if%>

Open in new window


It isn't however telling me how to correct the error.

Grateful for thoughts - thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sudaraka WijesingheWeb Application Programmer

Commented:
Looks like you are missing one EndIf:
<%IF RsProductDetail.Fields.Item("Image2") <> "" then %>
    <body onload="MM_preloadImages('<%=(RsProductDetail.Fields.Item("MainImage").Value)%>','<%=(RsProductDetail.Fields.Item("Image2").Value)%>
    <%IF RsProductDetail.Fields.Item("Image3") <> "" then %>
        ,'<%=(RsProductDetail.Fields.Item("Image3").Value)%>
    <%End if%>
    <%IF RsProductDetail.Fields.Item("Image4") <> "" then %>
        ,'<%=(RsProductDetail.Fields.Item("Image4").Value)%>
    <%End if%>
    <%IF RsProductDetail.Fields.Item("Image5") <> "" then %>
        ,'<%=(RsProductDetail.Fields.Item("Image5").Value)%>
    <%End if%>
    <%IF RsProductDetail.Fields.Item("Image6") <> "" then %>
        ,'<%=(RsProductDetail.Fields.Item("Image6").Value)%>')">
    <%Else%>
        <Body>
    <%End if%>

Open in new window

Commented:
<%
	Dim imgs
	imgs = ""
	If RsProductDetail.Fields.Item("Image2") <> "" Then 
		imgs = imgs + "'" + RsProductDetail.Fields.Item("MainImage").Value + "'"
		imgs = imgs + ",'" + RsProductDetail.Fields.Item("Image2").Value + "'"
		If RsProductDetail.Fields.Item("Image3") <> "" Then
			imgs = imgs + ",'" + RsProductDetail.Fields.Item("Image3").Value + "'"
		End If
		If RsProductDetail.Fields.Item("Image4") <> "" Then
			imgs = imgs + ",'" + RsProductDetail.Fields.Item("Image4").Value + "'"
		End If
		If RsProductDetail.Fields.Item("Image5") <> "" Then
			imgs = imgs + ",'" + RsProductDetail.Fields.Item("Image5").Value + "'"
		End If
		If RsProductDetail.Fields.Item("Image6") <> "" Then
			imgs = imgs + ",'" + RsProductDetail.Fields.Item("Image6").Value + "'"
		End If
		Response.Write ("<body onload=""MM_preloadImages(" +imgs + ");""")
	Else
		Response.Write ("<body>")
	End If
%>

Open in new window

Use this code and see. Use Response.Write whenever you have too many script blocks.

Author

Commented:
Neat thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial