Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Javascript & ASP Variables 1

Status
Not open for further replies.

budapestnori

Technical User
Jan 15, 2004
33
HU
Hi guys, So I am setting up a web site for a photographer. In his gallery, he will have five categories of images, ie., wedding, event, sports, etc. Normally, I would set up a template ASP page and pass it a variable such as cat=web in the url. Then, on the receiving page, I have a script that preloads images and populates an array for a slideshow presentation. Here is the problem I am up against. I want to allow him to enter as many images into the databaase as he wants to be in his gallery. So, for the array, I would need somehow to open the asp page, run a query to get a count of the records, build the array. Also, what about file names, I would name the images such as w_img_1,...w_img_21; e_img_1...e_img_17, etc. I think you see where I am going with this. I can get the data I want easily enough from the ASP knowledge that I know, it is just passing it to javascrip that is a challenge for me. Here is the link to the page I am working on, this would be the "receiving" page. Thanks in advance, you guys are so helpful.
 
you could build the js array using asp like so:
Code:
<script type=&quot;text/javascript&quot;>
var picArray = new Array(
<%
  comma = &quot;&quot;
  x = 1
  while not rs.eof
    response.write(comma & chr(34) & rs(&quot;fileName&quot;) & &quot;_&quot; & x & chr(34))
    comma = &quot;,&quot;
    x = x + 1
    rs.movenext()
  wend
%>
)
</script>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Hey, thanks so much. That did the trick and put me on the right path. One more question if I may, how do I create a new line for for a format like this:

dynimages[1]=[&quot;images/gallery/w_img_5.jpg&quot;, &quot;&quot;]
dynimages[2]=[&quot;images/gallery/w_img_3.jpg&quot;, &quot;&quot;]
dynimages[3]=[&quot;images/gallery/w_img_4.jpg&quot;, &quot;&quot;]
dynimages[4]=[&quot;images/gallery/w_img_2.jpg&quot;, &quot;&quot;]
dynimages[5]=[&quot;images/gallery/w_img_6.jpg&quot;, &quot;&quot;]

Do I insert a Chr(13) at the end of each iteration?

Take care.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top