Forum Moderators: open
The Situation:
He makes and sells pottery vases. He'd like to have an image gallery of thumbnails of his vases. When a user clicks on a thumb, they would receive information in the form of a larger picture, a brief description, and an input form that would take them to a payment website (I won't name names).
The Algorithm:
I already know I can grind this out by hand: write a little HTML file for each vase, and just open the appropriate file in a new window. But that's so tedious! We're talking dozens of vases, and he'll want to change and update it over time. I'm doing this for free just because I'm an idiot, and I'd REALLY like to make it SUPER SIMPLE to add new thumbs and vases. Besides, it's so much fun to flounder around the web Googling java sites and scratching my head, trying to find a more efficient way to do it...
My programmer instincts are to create some sort of array that contains
the image names, text and price to accompany the images, and unique code for the payment button that I need to send the payment site. Then when someone clicks on an image, some magical onClick function comes up and displays the proper information--either in a DIV or a new window--by referring to the array index for that vase. That way I can easily add new vases or change out sold ones, with a minimum of typing.
The Problem:
I haven't the foggiest idea how to do this!
I gather that Java allows you to create arrays, but even if I managed to kluge together the correct syntax, I wouldn't know what to do with the data. It's that magical onClick function that I'm hung up on.
Can I do an "a href" command to open a new window AND PASS THE ARRAY VARIABLES to the new window somehow? By googling I found a site talking about passing arguments around in HTML by putting an ? at the end of the cited URL, but it was dated 2003 and who knows if this still works (or if it ever really did?)
Can I use Java to open a new window or div? Java seems to have built in mechanisms for passing arguments, but my fund of Java knowledge could fit on an ant's tushie. I found a Java help forum that gave an example that kinda fit the bill. Here's the excerpt that caught my eye:
{
msg='<html><head><title>'+img+'<\/title>\n'+
'<\/head><body><div align="center"><h3>'+title+'<\/h3>\n'+
'<img src="'+img+'" width="'+w+'" height="'+h+'" border="0" ALT="'+title+'">\n'+
'<hr width="100%" size="1"><form action="" onSubmit="return false;">\n'+
'<input type="submit" onclick="javascript:window.close();" value="Close Window">\n'+
'<hr width="100%" size="1"><\/form><\/div><\/body><\/html>\n';
win = open('',id,params);
}
At first glance, this seemed to be just what I was looking for--a way to make the computer "write" the HTML file for the expanded view. But this particular routine just displays a large image when someone clicks the thumbnail. I also need to display text and an input form to the payment site. I thought the way to display the text might be as simple as
'<h2>'+vasename+'</h2>'+vasetext+'<br />\n'+
where vasename and vasetext were hard-coded in that array I mentioned earlier. But then how the heck do I tell it to display the pay site's input form? The pay site form has an "input type="submit" embedded in it--won't that be interpreted as a command for the browser to carry out on the spot, rather than a command to "Write the HTML code for this action and carry it out later."? ARGH!
And actually, I have a technical question: Where exactly is the above "msg" being written? Would the above routine create an actual HTML file that would take up space on my server? Or would this be a local memory phenomenon in the user's browser, which would go to Cyber Heaven when they surfed away?
I looked at some promising topics on this forum and didn't find anything off the cuff that answered my questions--but I did see that you guys seriously know your way around this whole Java thing. If anyone can take a few minutes to think about this odd little problem and offer some Very Detailed advice (because I'm too incompetent to make use of General Advice), I'd really appreciate it.
I'm a potter too; maybe I can mail you a cool handmade coffee mug or somethng. :-)
Thanks in advance,
Jeanine
For a task like this you need to decide what is best done on the server using a language like PHP and what is best done in the browser using javascript.
To keep it simple I would do it all on the server, one page per vase. So you would have a url like ../vase.php?vase=nnn. The vase.php file then generates the page based on nnn either from hard coded data or a database lookup.
For starters I would do PHP ( or other prefered language ) tutorial at w3schools
DaveVK: Oooh, now THAT looks promising. I've heard of PHP. It sounds pretty nifty! You know, one of the most difficult things for a wanna-be webmaster is to find basic instruction on this stuff. So many sites, so much of which are too advanced... I will check out w3schools.
Habtom: Oh, now come on, you're teasing me. I TOLD you I'm an extreme newbie, you don't have to go and point out that I can't even talk the language right. >P
Seriously, though, I have no idea what commercial programs there are out there. I run Windows 98 on my ancient machine (upgraded from 95 a couple years ago so I could use my nifty new digital camera), so a lot of them can't even function on my system. I don't use anything but a text editor to make websites. What can I say, I'm an old style fortran nut, I like to type my programs out by hand. Hey, it's a step above a punch card reader...
And BTW, don't make fun of my old Windows 98. The other day I got attacked by some sort of virus, and my OS was so decrepit, the executable just sat there and sputtered, popping up error messages and calling attention to itself. Poor young whippersnapper had no idea how to take over such a fossil machine.
Cheers,
Jeanine
OK, I'm liking your suggestions! I looked at the w3school for php and I'm totally thrilled to find this intro to, well, everything!
I'm still not sure I get this whole "put a ? on the end of your URL to pass an argument" business. I'm thinking the solution to my website is something like this: Each thumbnail is set up with a link to open up, thus:
<a href="vaselist.php?vase=1" target="_blank"><img src="thumb1.jpg"></a>
This would open the file vaselist.php, which would have a nice multidimensional array hardcoded with all the data for each vase, so it could display all the proper goodies.
But... How exactly do I tell the vaselist.php file that it will be receiving an argument? I mean, if it were a function, I'd just write
function vaselist(argument)
but I can't exactly write vaselist(argument).php as the filename! Do I have to use some sort of GET command?
Hopefully this is now a much simpler question... ?
There is a PHP forum on this site, you may wish to continue there.
I would also consider generating the thumbnail page from say vaselist.php?vase=0 so that your nice multidimensional array is available to populate image file names etc.
You know, I've made some real progress with the PHP stuff, I'm just thrilled you suggested it. I'm going to go over to the PHP board and bug THEM with my stupid questions. But thank you so much for pointing me toward w3schools! Maybe someday I'll actually know enough to post a DECENT question on this forum.
I was serious about the coffee cup--PM me if you want one. I'm a MUCH better potter than a webmaker. :)