problem when displaying image

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default problem when displaying image

    Hi,
    I made this code the retrive some info from my access DB, then choose
    another image from Products folder(images were not saved in DB)
    Everhthing is O.K., but when I changed the Image name from the drop down
    box the image became empty, and when I checked the image properties I
    found it looking in the same folder not in the Products folder.
    the question is how can I let the code display the image correctly ??
    here is my code:
    ======

    <!--#include file="database.asp"-->
    <script language="javascript">
    <!--
    function showimage()
    {
    if (!document.images)
    return
    document.images.pictures.src=document.MyForm.Image .options[document.MyFo
    rm.Image.selectedIndex].value
    }
    //-->
    </script>
    <%
    ID = Request.Querystring("ID")
    MySQL = "SELECT Product.ID, Product.Product_Name, Product.Product_Image
    WHERE Product.ID=" & ID & ""
    Set rs=Conn.Execute(MySQL)
    if rs.EOF Then
    respons.write("The product is not found.")
    Else
    %>
    <%
    ' Create an instance of the FileSystemObject
    Set MyFileObject=Server.CreateObject("Scripting.FileSy stemObject")
    ' Create Folder Object
    Set MyFolder=MyFileObject.GetFolder(Server.MapPath("/images/products/"))
    %>

    <input type="text" name="Product_Name" size="43"
    value="<%=rs("Product_Name")%>"></font>

    <p>
    <img border="0" src="../images/products/<%=rs("Product_Image")%>"
    Name="pictures">
    <br>
    <select size="1" Name="Image" onChange="showimage()">
    <option selected>-- ÇÎÊÑ ÕæÑÉ</option>
    <%
    'Loop trough the files in the folder
    FOR EACH thing in MyFolder.Files
    %>
    <option value="<%=thing.Name%>"><%=thing.Name%></option>
    <% next %>
    </select> </p>

    <%
    rs.close
    end if
    %>
    ======

    BTY I saved this code in another folder not in the Products folder.

    Thanks in advance

    A. J.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    A. J. Guest

  2. Similar Questions and Discussions

    1. Displaying part of an image
      I'm making a board game in Flex. Both to save bandwidth and for convenience in the code, I want to store the bitmaps for all the tiles in a single...
    2. Displaying an image
      I know there must be a simple answer to this question but researching dozens of php books and the web has not revealed an answer... How do I...
    3. Displaying image in browser but not source
      Hi, I have an 'invisible' image I would like to display in a php script I have just written. It does it's job fine, the only problem is that in IE...
    4. Displaying Larger Image On Rollover
      Hi Steve, You could use multiple disjointed rollovers. Since rollover slices don't have to be on top of each other or even adjacent, and one...
    5. Displaying Image on web page question
      My .php app displays an image on the web page, I notice that different ..jpg images display "funny" - apparently they all have slightly different...
  3. #2

    Default Re: problem when displaying image

    Guys is that true that you don't know anything about it ??? :(

    A. J.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    A. J. Guest

  4. #3

    Default Re: problem when displaying image

    A. J. wrote:
    > Guys is that true that you don't know anything about it ??? :(
    >
    > A. J.
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    The problem is that you've asked a client-side jscript coding question on an
    asp (server-side code) newsgroup. You'll get better response in the future
    by asking your questions on the appropriate group, such as
    m.p.scripting.jscript.

    Having said that, your problem is that you need to supply the entire path in
    this statement:

    document.images.pictures.src=document.MyForm.Image .options[document.MyFo
    rm.Image.selectedIndex].value

    in much the same way that you supplied it in this statement:
    <img border="0" src="../images/products/<%=rs("Product_Image")%>"
    Name="pictures">

    When you set the src property to something new, you are replacing EVERYTHING
    in the src property, not just the part of the string that follows the path.
    Try this:

    var newsrc="../images/products/" +
    document.MyForm.Image.options[document.MyFo
    rm.Image.selectedIndex].value;
    document.images.pictures.src=newsrc;

    Bob Barrows


    Bob Barrows Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139