...

View Full Version : Color Function help



tripwater
06-03-2005, 09:17 PM
I have a image of web color swatches. I am using mapping to tell my form what color they want. Example



<SCRIPT LANGUAGE=\"JavaScript\" type=\"text/javascript\">
function color_is_(cvalue)
{
document.addnotetype.color.value = cvalue;
}
</script>


<MAP NAME=\"spmap\">

<AREA SHAPE=\"RECT\" COORDS=\"1,1,7,10\" HREF=\"JavaScript:color_is_('#00FF00')\">
<AREA SHAPE=\"RECT\" COORDS=\"9,1,15,10\" HREF=\"JavaScript:color_is_('#00FF33')\">
<AREA SHAPE=\"RECT\" COORDS=\"17,1,23,10\" HREF=\"JavaScript:color_is_('#00FF66')\">
<AREA SHAPE=\"RECT\" COORDS=\"25,1,31,10\" HREF=\"JavaScript:color_is_('#00FF99')\">
<AREA SHAPE=\"RECT\" COORDS=\"33,1,39,10\" HREF=\"JavaScript:color_is_('#00FFCC')\">
<AREA SHAPE=\"RECT\" COORDS=\"41,1,47,10\" HREF=\"JavaScript:color_is_('#00FFFF')\">

</map>

<form name=\"addnotetype\">
<table>
<TR>
<TD>
Click a color below to assign a highlight color.<br>
<IMG SRC=\"../images/color_chart.gif\" BORDER=0 WIDTH=289 HEIGHT=67 USEMAP=\"#spmap\">
</TD>
<td>

Highlight Color<br>
<input type=text size=7 maxlength=7 name=color value=\"\">
</td>
</TR>
</table>
</form>


Everything I have here works fine. When you click a color it passes the hexidecimal color to my form field. But what I would like to do is in another data cell, actually change its BG color to what they clicked so they can see it on the page. How do I do this?

Thank you for any help with this.

_Aerospace_Eng_
06-03-2005, 09:23 PM
<SCRIPT LANGUAGE=\"JavaScript\" type=\"text/javascript\">
function color_is_(cvalue)
{
document.addnotetype.color.value = cvalue;
document.getElementById('thecolor').style.background=cvalue;
}
</script>


<MAP NAME=\"spmap\">

<AREA SHAPE=\"RECT\" COORDS=\"1,1,7,10\" HREF=\"javascript:color_is_('#00FF00')\">
<AREA SHAPE=\"RECT\" COORDS=\"9,1,15,10\" HREF=\"javascript:color_is_('#00FF33')\">
<AREA SHAPE=\"RECT\" COORDS=\"17,1,23,10\" HREF=\"javascript:color_is_('#00FF66')\">
<AREA SHAPE=\"RECT\" COORDS=\"25,1,31,10\" HREF=\"javascript:color_is_('#00FF99')\">
<AREA SHAPE=\"RECT\" COORDS=\"33,1,39,10\" HREF=\"javascript:color_is_('#00FFCC')\">
<AREA SHAPE=\"RECT\" COORDS=\"41,1,47,10\" HREF=\"javascript:color_is_('#00FFFF')\">

</map>

<form name=\"addnotetype\">
<table>
<TR>
<TD>
Click a color below to assign a highlight color.<br>
<IMG SRC=\"../images/color_chart.gif\" BORDER=0 WIDTH=289 HEIGHT=67 USEMAP=\"#spmap\">
</TD>
<td>

Highlight Color<br>
<input type=text size=7 maxlength=7 name=color value=\"\">

</td>
</TR>
<tr>
<td style=\"width:50px;height:50px;\" id=\"thecolor\">&nbsp;</td>
</tr>
</table>
</form>
From the looks of your code, you must be echoing some php. You do know you don't have to echo html, as it will get parsed as html without using echo, unless you are checking for something in particular.

vwphillips
06-03-2005, 09:28 PM
color='#123abc'

document.getElementBtId('myid').style.backgroundColor=color;

<input id="myid" size=2 type="text" >

or just about any element

see
http://www.codingforums.com/showthread.php?t=60175

vwphillips
06-03-2005, 09:31 PM
aero space beat me to it

tripwater
06-03-2005, 09:31 PM
Thanks _Aerospace_Eng_



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum