Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color Picker and Review before submit

Status
Not open for further replies.
Sep 1, 2000
119
US
I am looking to make a color picker and review before submit for a site theme admin tool.

I would like to have something display the color in addition to the HEX value in the text box in the color below. If you would point me to some source code that provides a good color picker and review, I would appreciate it.

Code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function showColor(val) {
	document.Form1.colorvalue.value = val;
}
//  End -->
</script>

</HEAD>
<BODY>
<form name=&quot;Form1&quot;>
<table border=0 bgcolor=&quot;FFFFFF&quot;>
	<tr>
		<td>Background Color:</font></td>
		<td><input type=&quot;text&quot; name=&quot;colorvalue&quot; size=10></td>
	</tr>
</table>
<table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<%
  dim intTableCellWidth, intTableCellHeight
	dim intBlue, intGreen, intRed, strColor
	dim aryColors(6)
	aryColors(1) = &quot;00&quot;
	aryColors(2) = &quot;33&quot;
	aryColors(3) = &quot;66&quot;
	aryColors(4) = &quot;99&quot;
	aryColors(5) = &quot;CC&quot;
	aryColors(6) = &quot;FF&quot;
	for intBlue = 1 to 6
		%><tr><%
		for intGreen = 1 to 6
			for intRed = 1 to 6
				strColor = aryColors(intRed) &amp; aryColors(intGreen) &amp; aryColors(intBlue)
					%><td width=&quot;15&quot; height=&quot;15&quot; align=&quot;center&quot; bgcolor=&quot;<%=strColor%>&quot; onmousedown=&quot;javascript:showColor('#<%=strColor%>')&quot;></td><%
			next
		next
		%><tr><%
		Response.write(vbCrLF)		
	next
%>
</table>
<font face=&quot;<%=session(&quot;Font_Face&quot;)%>&quot; color=&quot;FF0000&quot; size=&quot;-2&quot;>
Click a box and the hexadecimal color will be shown below.</font><br>
</form>
</BODY>
</HTML>
Steven Fowler, Principal
steve.fowler@fowlerconsulting.com
- Development, Training, and Consulting
wpe1.gif
 
Here's a simple example:

<input type=&quot;text&quot; size=&quot;7&quot; maxlength=&quot;7&quot; name=&quot;colorvalue&quot; value=&quot;#FFFFFF&quot; style=&quot;color:#000000; background-color:#FFFFFF&quot; onBlur=&quot;this.style.color=this.value;&quot;>

But, then you have to deal with whether the font contrasts enough with the background to see a difference.

You could do this:
<div id=&quot;show_color&quot;><img src=&quot;blank.gif&quot; width=&quot;10&quot; height=&quot;10&quot;></td>

<input type=&quot;text&quot; size=&quot;7&quot; maxlength=&quot;7&quot; name=&quot;colorvalue&quot; value=&quot;#FFFFFF&quot; style=&quot;color:#000000; background-color:#FFFFFF&quot; onBlur=&quot;document.show_color.style.color=this.value;&quot;>

And that would set the value of another layer to be the color in the text box.

For a more complete and complex example, I think this would be extremely useful:

Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top