howardfan123 Posted April 8, 2009 Share Posted April 8, 2009 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 More sharing options...
Egern.net Posted April 8, 2009 Share Posted April 8, 2009 a sample of the color in another box next to itDo 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 More sharing options...
Egern.net Posted April 8, 2009 Share Posted April 8, 2009 question # 2 can a form tag be inside another form tag?No, it's a validation error I think...But why do you need it? Link to comment Share on other sites More sharing options...
virgil Posted April 8, 2009 Share Posted April 8, 2009 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 More sharing options...
howardfan123 Posted April 8, 2009 Author Share Posted April 8, 2009 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 More sharing options...
jesh Posted April 8, 2009 Share Posted April 8, 2009 NEST? what does that mean?if you mean form tag inside anotherYes, that's what nesting means. And no, you're not supposed to do it in HTML. You'll have to modify your code. Link to comment Share on other sites More sharing options...
howardfan123 Posted April 8, 2009 Author Share Posted April 8, 2009 Yes, that's what nesting means. And no, you're not supposed to do it in HTML. You'll have to modify your code.could i asign it an id inplace of the form tag Link to comment Share on other sites More sharing options...
howardfan123 Posted April 8, 2009 Author Share Posted April 8, 2009 could i asign it an id inplace of the form taghow 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.