Jump to content

Color Picker


howardfan123
 Share

Recommended Posts

i am trying to write a script that when a visiter clicks on a color map it will put the hex# in a text box and a sample of the color in another box next to it. i have to have this in about 6 spots through out the page. this is what i have so far and it is not working any ideas? all of this is going to go into the middle of another form, so i pieced it together for this example.question # 2 can a form tag be inside another form tag?

<script LANGUAGE="JavaScript">var which = 0;function showColor(val) {document.colortable.elements["hexval"+which].value = val;}</script>

here is the map

<map name="colmap"><area shape="rect" coords="1,1,7,10" href="java script:showColor('#00FF00')" /><area shape="rect" coords="9,1,15,10" href="java script:showColor('#00FF33')" /><area shape="rect" coords="17,1,23,10" href="java script:showColor('#00FF66')" /><area shape="rect" coords="25,1,31,10" href="java script:showColor('#00FF99')" /><area shape="rect" coords="33,1,39,10" href="java script:showColor('#00FFCC')" /><area shape="rect" coords="41,1,47,10" href="java script:showColor('#00FFFF')" /><area shape="rect" coords="49,1,55,10" href="java script:showColor('#33FF00')" /><area shape="rect" coords="57,1,63,10" href="java script:showColor('#33FF33')" /><area shape="rect" coords="65,1,71,10" href="java script:showColor('#33FF66')" /><area shape="rect" coords="73,1,79,10" href="java script:showColor('#33FF99')" /><area shape="rect" coords="81,1,87,10" href="java script:showColor('#33FFCC')" /><area shape="rect" coords="89,1,95,10" href="java script:showColor('#33FFFF')" />so on and so on</map>

two pair of the boxes but there will be 4 pairs total

<input type="text" name="hexval0" size="10" readonly="true" id="hexval0" class="fontwording"/><input type="text" ID="sample_0" size="1" value=""><input type="text" name="hexval1" size="10" readonly="true" id="hexval1" class="fontwording"/><input type="text" ID="sample_1" size="1" value="">

Link to comment
Share on other sites

a sample of the color in another box next to it
Do you want to fill the another box with that color? (couldn't understand)
document.getElementById("sample_"+which).style.backgroundColor = val;

?

Link to comment
Share on other sites

try this code

<script LANGUAGE="JavaScript">var which = 0;function showColor(val) {document.getElementById("hexval"+which).value = val;document.getElementById("sample_"+which).style.backgroundColor = val;}</script>

can you tell us why you need to nest forms.

Link to comment
Share on other sites

try this code
<script LANGUAGE="JavaScript">var which = 0;function showColor(val) {document.getElementById("hexval"+which).value = val;document.getElementById("sample_"+which).style.backgroundColor = val;}</script>

can you tell us why you need to nest forms.

NEST? what does that mean?if you mean form tag inside another it is because the script i took the map from had a form tag right before the map id and i am trying to put all of this stuff in a form i already made
Link to comment
Share on other sites

NEST? what does that mean?if you mean form tag inside another
Yes, that's what nesting means. And no, you're not supposed to do it in HTML. You'll have to modify your code. Edited by jesh
Link to comment
Share on other sites

could i asign it an id inplace of the form tag
how do i do the attritude on the img map?
<img src="FUNDRAISING/colortable.gif" alt="COLOR TABLE" width="289" height="67" border="0" usemap="#colmap" id="subheading2font" onclick="showcolor(this);"/>

and the text boxes show it be like this

<input type="text" name="hexval0_0" size="10" readonly="true" id="showcolor_subheading2font(hexval0)" class="fontwording"/>

i kind of understand what you are tell me but i seem to be missing something, cant figure it out

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...