I have to create a page where you can use a graphic interface to select options and then display a finished product.
To simplify just know that there are three variables - top, bottom, color.
Each variable has 3 types. TopStyle1, TopStyle2, TopStyle3 ... BottomStyle1, BottomStyle2, BottomStyle3 ... Color1, Color2, Color3.
So I have an image for each style, so when you select (onClick) TopStyle1. I the image representing TopStyle1 changes to an "On" State (just a different image with a gold circle around it indicating your selection) and TopStyle2 and TopStyle3 change to an "Unselected" state (images change to grayed out versions of themselves). If you click on TopStyle1 again all there Styles change to an "Off" state (their original images).
I found code to do all this, may not be the most efficient way but it works
function topstyle1() {
if (document.getElementById("style1-top").src == "<%= bse%>images/style1-top-OFF.jpg")
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-ON.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-DIS.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-DIS.jpg";
var top="style1";
}
else if (document.getElementById("style1-top").src == "<%= bse%>images/style1-top-DIS.jpg")
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-ON.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-DIS.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-DIS.jpg";
var top="style1";
}
else
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-OFF.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-OFF.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-OFF.jpg";
var top="";
}
}
function topstyle2() {
if (document.getElementById("style2-top").src == "<%= bse%>images/style2-top-OFF.jpg")
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-DIS.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-ON.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-DIS.jpg";
var top="style2";
}
else if (document.getElementById("style2-top").src == "<%= bse%>images/style2-top-DIS.jpg")
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-DIS.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-ON.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-DIS.jpg";
var top="style2";
}
else
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-OFF.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-OFF.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-OFF.jpg";
var top="";
}
}
function topstyle3() {
if (document.getElementById("style3-top").src == "<%= bse%>images/style3-top-OFF.jpg")
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-DIS.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-DIS.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-ON.jpg";
var top="style3";
}
else if (document.getElementById("style3-top").src == "<%= bse%>images/style3-top-DIS.jpg")
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-DIS.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-DIS.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-ON.jpg";
var top="style3";
}
else
{
document.getElementById("style1-top").src = "<%= bse%>images/style1-top-OFF.jpg";
document.getElementById("style2-top").src = "<%= bse%>images/style2-top-OFF.jpg";
document.getElementById("style3-top").src = "<%= bse%>images/style3-top-OFF.jpg";
var top="";
}
}
At the end of each function, after the images are change I'm trying to set a variable based on which function is called.
So if you click on TopStyle1 you var top="style1" ... if you change it to TopStyle2 var top="style2" and so on.
After you've chosen your Top, Bottom, and Color there is a button that will say "View Completed Item." When you click on this button I want to call a new function that will display an image based on your choices. For now I'd be happy just displaying the text from the variables but I don't know how to get them to show up.
I've tried this:
function changeImage() {
document.getElementById("display").innerHTML=top;
}
But I think the contents of the variable are gone when I get to this point.
There has to be a way to set the variable based on my selections and then call them in another function, but my with my inexperience I'm having a hard time finding the answer.