View Full Version : Option has to be selected on page load
Yammaski
03-26-2010, 09:33 AM
With a selectmenu you can change the color of a picture.
But when the page loads, the picture has the same color as the background because it's a transparant png. I change the bgcolor instead of the picture.
http://www.frogstyling.be/X_Tests/bg_change_pt.asp
The color only appears when choosing one in the menu.
I want that the picture already has a color when page loads.
I guess it's a adjusting of the code, but how ?
vwphillips
03-26-2010, 10:10 AM
<html><head>
<title>bg_change_pt</title>
<script type="text/javascript">
function changeBG(color) {
switch(color) {
case 'Black':
color='#000000';
break;
case 'White':
color='#FFFFFF';
break;
case 'Yellow':
color='#FFB600';
break;
}
element=document.getElementById('Back_Transp_PNG').style;
element.background=color;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
background-color: #CCCCCC;
}
-->
</style>
</head>
<body onload="changeBG('Yellow');">
<table width="440" border="0" align="center" cellpadding="0" bgcolor="#E6E6E6">
<tr align="center" >
<td><div id="Back_Transp_PNG"><img src="http://www.frogstyling.be/X_Tests/Jack.png" width="441" height="305"></div></td>
</tr>
<tr align="center" bgcolor="#999999">
<td><form action="">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" align="center">
<select name="FrogStyling_1_Color_Add" onChange="changeBG(this.value)">
<option value="Black" style="background-color:#000000; color:#FFFFFF ">Black</option>
<option value="White" style="background-color:#FFFFFF; color:#000000 ">White</option>
<option value="Yellow" style="background-color:#FFB600; color:#000000 ">Yellow</option>
</select>
</td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
Yammaski
03-26-2010, 10:36 AM
Thanks ! :D
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.