Update Colour

S

SGTPEP

Hi

I have a simple RGB to Hex converter. The user enters three RGB values and
clicks on a button that converts it to Hex.

I would now like to update the colour of the body of the page to be the
colour the user enters

Here is the existing code

<HTML>
<HEAD>
<title> RGB-to-Hex Conversion</title>
</HEAD>
<body text="#000000" link="#0000FF" vlink="#660099"
onLoad="if(top.changeAD)top.changeAD()">
<a name="top"></a>

<h3><font face="Verdana,Arial,Helvetica,sans-serif" color="#000099">
RGB-to-Hex Conversion
</font></h3>

<script language="JavaScript">
<!--
if (
parent.location==self.location
&& (""+self.location).toLowerCase().indexOf(".chm")==-1
&& (""+self.location).toLowerCase().indexOf("~hh")==-1
)

//-->
</script>


<script language="JavaScript">
<!--
function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
if (N==null) return "00";
N=parseInt(N); if (N==0 || isNaN(N)) return "00";
N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
return "0123456789ABCDEF".charAt((N-N%16)/16)
+ "0123456789ABCDEF".charAt(N%16);
}
//-->
</script>


<form name=rgb>
R:<input type=text name=r size=3 value=255>
G:<input type=text name=g size=3 value=55>
B:<input type=text name=b size=3 value=2>

<input type=button name=btn value="Convert to Hex
onCLick="this.form.hex.value=RGBtoHex(this.form.r.value,this.form.g.value,this.form.b.value)">
<input type=text name=hex size=8>
</form>


<body bgcolor =

<!--Page content ends here; don't delete this comment.-->



</BODY>

</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top