[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

ASP VBScript - better way of scripting ...

Please can you let me know if there is a better way of scripting these two conditional statements --

        <td class="img-preview-column">
		<% If Not RsImages.EOF then%>
        <% IF RsImages.Fields.Item("image1") <> "" Then %>
            <img src="<%="http://my.website.com/product-images/"&(RsImages.Fields.Item("image1").Value)%>" />
            <% End If %>
            <%End if%>
            </td>
        <td><input name="image2" type="file" id="image2" value="<% If Not RsImages.EOF then%><% IF RsImages.Fields.Item("image1") <> "" Then %><%=(RsImages.Fields.Item("image1").Value)%><% End If %><%End if%>" /></td>

Open in new window


Many thanks
0
garethtnash
Asked:
garethtnash
  • 3
2 Solutions
 
pritamduttCommented:
I would suggest you to do something like below

<% If Not RsImages.EOF And RsImages.Fields.Item("image1") <> "" Then
imgFile = RsImages.Fields.Item("image1").Value
End If
%>
<img src="<%=imgFile%>"...

This will help remove the repetitions of the code, and also improve performance by accessing data from variable instead of File.

0
 
Wayne BarronCommented:
Get rid of all the unnecessary coding.

 
        <td class="img-preview-column">
		<% If Not RsImages.EOF then
		Image1 = RsImages("image1")%>
        <% IF Image1 <> "" Then %>
            <img src="<%="http://www.mydomain.com/product-images/"&Image1%>" />
            <% End If %>
            <%End if%>
            </td>
        <td><input name="image2" type="file" id="image2" value="<% If Not RsImages.EOF then%><% IF Image1 <> "" Then %><%=Image1%><% End If %><%End if%>" /></td>

Open in new window


Carrzkiss
0
 
garethtnashAuthor Commented:
Great thank you
0
 
garethtnashAuthor Commented:
Please can I just quickly check this with you both, based on the above logic, will the following work / is the following the best way of writing --

<%
If Not RsImages.EOF then
Image1 = RsImages("image1")
Image2 = RsImages("image2")
Image3 = RsImages("image3")
Image4 = RsImages("image4")
Image5 = RsImages("image5")

IF Image1 <> "" Then
Session("OLDImage2") = (Image1)
End If

IF Image2 <> "" Then
Session("OLDImage3") = (Image2)
End If

IF Image3 <> "" Then
Session("OLDImage4") = (Image3)
End If

IF Image4 <> "" Then
Session("OLDImage5") = (Image4)
End If

IF Image5 <> "" Then
Session("OLDImage6") = (Image5)
End If
End If
%>

Open in new window


Appreciate your help --

Many thanks
0
 
garethtnashAuthor Commented:
Got it - thanks

Ignore last post - unless there is a better way -- TY
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now