Attribute Selection and JavaScript
I'm having a bit of a problem here, and was hoping one of you JavaScript genius' could help me out here.
On a products page, the user must select a font to be used from a dropdown. The dropdown (attribute ID 49) is set to "5 year Old" font (option value 336) by default. I need this to display "5yrold.jpg"....which I can do by adding the img src in the comments. Now, say the user selects the last font on the list....Wedding Text BT (option value 385), in which the image needs to change appropriately to "wed_txt.jpg" upon selection so the user can see the font they're getting.
I also have a link for them to view all fonts all at once, using JavaScript (although I can't get the image to come up full size in the new window.....it's small with a magnifying glass. Maybe somebody could tell me how to fix this, as well?), but I really need to get this done, if somebody could show me what I'm missing here and how to translate this into Zen-Cart terms, I would be VERY grateful.
The code I was told I could use (from the WebDeveloper formu) looks like this:
Code:
<SELECT id="fontSel" onChange="changePicture(this.value);">
Which I'm not sure where to put.......
And:
Code:
function changePicture(pValue)
{
var vSelection = "5yrold.jpg";
switch(pValue)
{
case "385": vSelection = "wed_txt.jpg";
break;
case ...
//add all images here
}
document.getElementById("imagethathastochange").src = vSelection;
}
I'm not absolutely sure where to put this, either, but though it would be something that should be added to "html_header.php"......would that be correct?
I was also told that the "imagethathastochange" is the ID of the image I want to use.......does that mean the image NAME, or what?
I've tried this code seems like a thousand different ways to no avail. But, of course, I am totally JavaScript illiterate, and was guessing at most of this.
If it helps any, my font's images are in images/attributes/fonts.
I swear I'm going to learn JavaScript one of these days.......it's so frustrating wanting to do something that's probably soooo simple for someone that knows JavaScript.
Thanks,
Robert
Teach them to shop and they will shop today;
Teach them to Zen and they will OWN a shop tomorrow!