Display images name thrue drop down box

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

  1. #1

    Default Display images name thrue drop down box

    Hi,
    I have a folder include images and i want to disply the names of these
    images in drop down box and when i change the name the image also
    change.
    I wrote these code to to that
    =========
    <html>
    <head>
    <script language="javascript">
    <!--
    function showimage()
    {
    if (!document.images)
    return
    document.images.pictures.src=
    document.mygallery.picture.options[document.mygallery.picture.selectedIn
    dex].value
    }
    //-->
    </script>
    </head>

    <body>
    <%
    ' Create an instance of the FileSystemObject
    Set MyFileObject=Server.CreateObject("Scripting.FileSy stemObject")
    ' Create Folder Object
    Set
    MyFolder=MyFileObject.GetFolder(Server.MapPath("/zad-alrida/images/produ
    cts/"))
    response.write(MyFolder)
    'Loop trough the files in the folder
    FOR EACH thing in MyFolder.Files
    %>

    <form name="mygallery"><p><select name="picture" size="1"
    onChange="showimage()">

    <option selected value="<%=thing.Name%>"><%=thing.Name%></option>
    </select>
    <img src="<%=thing.Name%>" name="pictures" width="99" height="100">
    <% next %>
    </form>
    </body>
    </html>
    =========
    but everytime I run this script all images are dsiplay at the same time
    :(
    do you have any solution ???

    Thanks in advance
    A. J.

    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. Images blocking the Drop down Menu
      Hi, I created a drop down menu. But blocked with images below. What can I do? Please help, Thanks! Mikeco
    2. implementation of Affiliates program thrue linkshare
      Hi, Has anybody implemented an Affiliates program from some comapny as i have to implement the same in my company. LinkShare functions as an...
    3. Images in a drop down
      Can images be rendered in a drop down object. I create subscripts and superscripts as images in fireworks and then place the path of the image in a...
    4. drop down list always a vertical display
      Okay. I followed the steps from a MS KB article (306227, i think) about how to create a frop down box in a data grid, and bind to data. However,...
    5. Drop shadow and display performance
      Has anyone else noticed that applying drop shadow affects the display performance of the spread you're working on - making the type etc look bitty or...
  3. #2

    Default Re: Display images name thrue drop down box

    To help you think through the process, indent each line of code or HTML
    according to what's happening. (You don't have to save your code with the
    indentations if you don't want to, but it will help.

    Here's an example of what I mean:
    <snip>
    ...

    'Loop trough the files in the folder
    FOR EACH thing in MyFolder.Files
    %>

    <form name="mygallery"><p>
    <select name="picture" size="1" onChange="showimage()">
    <option selected
    value="<%=thing.Name%>"><%=thing.Name%></option>
    </select>
    <img src="<%=thing.Name%>" name="pictures" width="99" height="100">
    <% next %>
    </form>

    ...
    </snip>

    Do you see how things don't quite match up? For example, the opening <form>
    tag occurs inside your For/Next loop, but the closing tag occurs outside the
    loop. Your <select> tag and <img> tag also are inside the loop. That means
    as the code runs, you will get many forms (which won't work), many drop-down
    lists with only one item, and many images--one for EACH file in your folder.

    Now think about what you WANT to happen. You want one form, and one image,
    but multiple options in your drop-down list. Without showing you the code
    (the poeple in the groups made me learn on my own, too), you need to change
    your loop so that only the <option> tags are repeated--one element for each
    file in your folder.

    One last note is that if you want the <img> to show the first picture by
    default, you'll either need to use client script or add a variable to your
    ASP that stores the name of the first file (e.g. replaces
    src="<%=thing.Name%>" with src="<%=strFirstPictureName%>"

    Hope that gets you started,
    Boris

    "A. J." <a_jifri@hotmail.com> wrote in message
    news:%23qBUYGvcDHA.1580@tk2msftngp13.phx.gbl...
    > Hi,
    > I have a folder include images and i want to disply the names of these
    > images in drop down box and when i change the name the image also
    > change.
    > I wrote these code to to that
    > =========
    > <html>
    > <head>
    > <script language="javascript">
    > <!--
    > function showimage()
    > {
    > if (!document.images)
    > return
    > document.images.pictures.src=
    > document.mygallery.picture.options[document.mygallery.picture.selectedIn
    > dex].value
    > }
    > //-->
    > </script>
    > </head>
    >
    > <body>
    > <%
    > ' Create an instance of the FileSystemObject
    > Set MyFileObject=Server.CreateObject("Scripting.FileSy stemObject")
    > ' Create Folder Object
    > Set
    > MyFolder=MyFileObject.GetFolder(Server.MapPath("/zad-alrida/images/produ
    > cts/"))
    > response.write(MyFolder)
    > 'Loop trough the files in the folder
    > FOR EACH thing in MyFolder.Files
    > %>
    >
    > <form name="mygallery"><p><select name="picture" size="1"
    > onChange="showimage()">
    >
    > <option selected value="<%=thing.Name%>"><%=thing.Name%></option>
    > </select>
    > <img src="<%=thing.Name%>" name="pictures" width="99" height="100">
    > <% next %>
    > </form>
    > </body>
    > </html>
    > =========
    > but everytime I run this script all images are dsiplay at the same time
    > :(
    > do you have any solution ???
    >
    > Thanks in advance
    > A. J.
    >
    > A. J.
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Boris Nikolaevich Guest

  4. #3

    Default Re: Display images name thrue drop down box

    You know, when i use your modify the images still disply many times, but
    I need it to be one image and one drop down box which include images
    name ...
    Please I really need your advice

    A. J.

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

  5. #4

    Default Re: Display images name thrue drop down box

    My modification of your code was NOT a suggestion on how to write the
    function correctly, it was a suggestion on how to identify the error. Doing
    that will be way more help than having someone post the correct code for
    you.

    Have you been able to get your script to work correctly? If you are still
    having the same problem, I can post some additional advice.

    "A. J." <a_jifri@hotmail.com> wrote in message
    news:uXqKHjAdDHA.560@TK2MSFTNGP11.phx.gbl...
    > You know, when i use your modify the images still disply many times, but
    > I need it to be one image and one drop down box which include images
    > name ...
    > Please I really need your advice
    >
    > A. J.
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Boris Nikolaevich Guest

  6. #5

    Default Re: Display images name thrue drop down box

    Thanks a lot Mr Boris, it's working great now

    A. J.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    A. J. 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