RotoGuru Computer Forum

View the Forum Registry


Self-edit this thread


0 Subject: Experts = Need help with Javascript / Database?

Posted by: Promize
- [28839168] Thu, Sep 23, 2004, 15:13

I found a pretty simple javascript code that would work great for a project I am doing. Thing is, instead of 5 pictures, I have 100's of pictures.

Is there a way I could modify this program, so that it read from like an Access database the address of the image (images/pic.jpg) and title of the image ("Bob at the park")..... Instead of listing them all?

================================================

<SCRIPT LANGUAGE="JavaScript">

var num=1
img1 = new Image ()
img1.src = "information.gif"
img2 = new Image ()
img2.src = "interference.gif"
img3 = new Image ()
img3.src = "message.gif"
img4 = new Image ()
img4.src = "nervous.gif"

text1 = "Text for Picture One"
text2 = "Text for Picture Two"
text3 = "Text for Picture Three"
text4 = "Text for Picture Four"

function slideshowUp()
{
num=num+1
if (num==5)
{num=1}
document.mypic.src=eval("img"+num+".src")
document.value=eval("text"+num)
}

function slideshowBack()
{
num=num-1
if (num==0)
{num=4}
document.mypic.src=eval("img"+num+".src")
document.value=eval("text"+num)
}





<CENTER>
<IMG SRC="information.gif" NAME="mypic" BORDER=0 HEIGHT="100" WIDTH="100">
<p>

<FORM NAME="pictureshow">
<INPUT TYPE="text" WIDTH="100" NAME="show" VALUE="Text For Picture One">


<A HREF="JavaScript:slideshowBack()"> Back

<A HREF="JavaScript:slideshowUp()"> Next


1James K Polk
      ID: 108342315
      Thu, Sep 23, 2004, 16:43
Are you strictly HTML/Javascript, or can you do VBscript and ASP?
2Promize
      ID: 28839168
      Thu, Sep 23, 2004, 17:07
I'm up for anything, what I want is for people to be able to search through a database of pictures. If they like the picture they click it on to take a bigger look at it.

The ultimate goal is, if they really like it, they will want to buy the image.

I've used Paintshop pro to create a nice little picture frame. And want the picture in the middle to change when they press forward or backwards..

This is rough draft of what I have started...

Picture Frame

3James K Polk
      ID: 51010719
      Thu, Sep 23, 2004, 17:44
Here is a gallery I did for a project at work, which lets you look at a selection of thumbnails, then click to get a bigger view of the pic. Once there, you can browse sequentially through the larger pics if you like. Take a look and see if that part does something similar to what you're after.
4 Promize
      ID: 28839168
      Thu, Sep 23, 2004, 20:53
I like that, now is the page refreshing each time you hit the next button? I guess that isn't a problem, although was trying to make it so just the image refreshed.

Other then that, yes, that is basically what I was trying to do. Although, if someone came to a picture they liked, they could click it to get the full image.
5James K Polk
      ID: 51010719
      Thu, Sep 23, 2004, 21:12
Yes, in this case the page is refreshing each time. Making a call to the database to get the proper pic, text, etc. There's not too much overhead on the page, so it's no big deal, but that could be different in your case I suppose.

All I'm doing is, once I've called the database for the relevant info to display, using vbscript to create +1 and -1 variables to feed the next and prev buttons. Not a particularly hard piece of code. But when they click on a nav button, it passes that new id to the page as it reloads, so that the SQL query pulls in info for the new photo. It would be very easy in the template to make the pic clickable to show a larger version too.

If you're interested, I can email you the code behind that template page so you can see if something similar might work for you.
6Promize
      ID: 28839168
      Thu, Sep 23, 2004, 21:40
sure, the email link is above...

Appreciate it...
7James K Polk
      ID: 51010719
      Thu, Sep 23, 2004, 21:52
on the way ...
RotoGuru Computer Forum

View the Forum Registry


Self-edit this thread




Post a reply to this message: (But first, how about checking out this sponsor?)

Name:
Email:
Message:
Click here to create and insert a link
Ignore line feeds? no (typical)   yes (for HTML table input)


Viewing statistics for this thread
Period# Views# Users
Last hour11
Last 24 hours11
Last 7 days22
Last 30 days22
Since Mar 1, 2007590311