jigarshah
10-13-2006, 07:55 AM
1) Script Title:
Stylesheet switcher
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm
3) Describe problem:
i have created new thread ....please help me
Instead of using radio button to select stylesheet i want to use menu with images. when i select any color i want to change selected image tansperancy through css.
Actual code is like below
<div id="colormenu">
<ul>
<li><a href="#" type="image" name="color_image" id="blue" onClick="chooseStyle(this.id, 60)"><img src="images/colors_blue.jpg " alt="blue" /></a></li>
<li><a href="#" type="image" name="color_image" id="orange" onClick="chooseStyle(this.id, 60)"><img src="images/colors_orange.jpg" alt="blue" /></a></li>
<li><a href="#" type="image" name="color_image" id="red" onClick="chooseStyle(this.id, 60)"><img src="images/colors_red.jpg" alt="red" /></a></li>
for selected color
<li><a class="current" href="#" type="image" name="color_image" id="red" onClick="chooseStyle(this.id, 60)"><img src="images/colors_red.jpg" alt="red" /></a></li>
css is
#colormenu a.current img {
background:#f0f0f0;
color:#505050;
border-right:1px solid #505050 ;
border-top:1px solid #505050 ;
border-bottom:1px solid #505050 ;
border-left:1px solid #505050 ;
padding:3px 3px 3px 3px;
opacity: 1;
filter: alpha(opacity=100);}
Problem is i tried using java script to changes class of href. something as below.
function setSelectedStyle(styletitle) {
elements = document.getElementsByName("color_image")
var i
for (i=0; i < elements.length; i++)
{
if(elements[i].id==selectedtitle)
{
alert("item is " + elements[i].id)
elements[i].class="current"
}
else
{
alert("item is none")
}
break;
}
}
Its not working. It does not give any error in javascript console(FF). what went wrong with this code?
Stylesheet switcher
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm
3) Describe problem:
i have created new thread ....please help me
Instead of using radio button to select stylesheet i want to use menu with images. when i select any color i want to change selected image tansperancy through css.
Actual code is like below
<div id="colormenu">
<ul>
<li><a href="#" type="image" name="color_image" id="blue" onClick="chooseStyle(this.id, 60)"><img src="images/colors_blue.jpg " alt="blue" /></a></li>
<li><a href="#" type="image" name="color_image" id="orange" onClick="chooseStyle(this.id, 60)"><img src="images/colors_orange.jpg" alt="blue" /></a></li>
<li><a href="#" type="image" name="color_image" id="red" onClick="chooseStyle(this.id, 60)"><img src="images/colors_red.jpg" alt="red" /></a></li>
for selected color
<li><a class="current" href="#" type="image" name="color_image" id="red" onClick="chooseStyle(this.id, 60)"><img src="images/colors_red.jpg" alt="red" /></a></li>
css is
#colormenu a.current img {
background:#f0f0f0;
color:#505050;
border-right:1px solid #505050 ;
border-top:1px solid #505050 ;
border-bottom:1px solid #505050 ;
border-left:1px solid #505050 ;
padding:3px 3px 3px 3px;
opacity: 1;
filter: alpha(opacity=100);}
Problem is i tried using java script to changes class of href. something as below.
function setSelectedStyle(styletitle) {
elements = document.getElementsByName("color_image")
var i
for (i=0; i < elements.length; i++)
{
if(elements[i].id==selectedtitle)
{
alert("item is " + elements[i].id)
elements[i].class="current"
}
else
{
alert("item is none")
}
break;
}
}
Its not working. It does not give any error in javascript console(FF). what went wrong with this code?