![]() Topic awaiting preservation: Passing JS Variables (Page 1 of 1) |
|
---|---|
Neurotic (0) Inmate Newly admitted From: |
![]() apparently I've forgotten my password... code: <html> <head> <script language="JavaScript"> <!-- var crayola = new Array( "000000", "000040", "000080", "0000FF", "004000", "004040", "004080", "0040FF", "008000", "008040", "008080", "0080FF", "00FF00", "00FF40", "00FF80", "00FFFF", "400000", "400040", "400080", "4000FF", "404000", "404040", "404080", "4040FF", "408000", "408040", "408080", "4080FF", "40FF00", "40FF40", "40FF80", "40FFFF", "800000", "800040", "800080", "8000FF", "804000", "804040", "804080", "8040FF", "808000", "808040", "808080", "8080FF", "80FF00", "80FF40", "80FF80", "80FFFF", "FF0000", "FF0040", "FF0080", "FF00FF", "FF4000", "FF4040", "FF4080", "FF40FF", "FF8000", "FF8040", "FF8080", "FF80FF", "FFFF00", "FFFF40", "FFFF80", "FFFFFF" ); function fShowData(ind) { alert(crayola[ind]); } function fBuildTable() { var ind=0; document.write('<table style="border: 1px solid #000000;">'); for(y=0;y<=7;y++){ document.write('<tr>'); for(x=0;x<=7;x++){ document.write('<td ' + 'style="cursor: hand; ' + 'background: #' + crayola[ind] + '; ' + 'color: #' + crayola[ind] + '; border: 1px solid #000000;"' + ' onClick=JavaScript:fShowData(this.innerHTML)>' + ind + '</td>'); ind = ind + 1; } document.write('</tr>'); } document.write('</table>'); } --> </script> </head> <body> <script language="JavaScript"> javascript:fBuildTable(); </script> </body> </html>
|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
![]() Okay well if this is going to be in a popup. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
![]() Also the document.write methods are bad. |
Obsessive-Compulsive (I) Inmate From: |
![]() thanks for the help, bitdamaged, that should be what I'm looking for |
Nervous Wreck (II) Inmate From: beyond the looking glass |
![]() code: function fShowData(ind, myElement) { alert(crayola[ind]); document.getElementById(myElement).value=crayola[ind]; window.parent.document.forms.stylesheet.elements.hex.value=crayola[ind]; } function fBuildTable() { var ind=0; document.write('<table id="colorTable">'); for(y=0;y<=7;y++){ document.write('<tr>'); for(x=0;x<=7;x++){ document.write('<td id="colorCell"' + 'style="background: #' + crayola[ind] + '; ' + 'color: #' + crayola[ind] + '; border: 1px solid #000000;"' + ' onClick=JavaScript:fShowData(this.innerHTML,"hex")>' + ind + '</td>'); ind = ind + 1; } document.write('</tr>'); } document.write('</table>'); }
code: <script language="JavaScript"> function popWin(url){ newwindow=window.open(url, 'name', 'height=400,width=275' + ',toolbar=no,status=yes,menubar=no,directories=no' + ',location=no,resizable=yes,scrollbars=auto'); if (window.focus){ newwindow.focus() } } </script> <a href="javascript:popWin('test.html')">Background</a>
|
Nervous Wreck (II) Inmate From: beyond the looking glass |
![]() I'm still having troubles with this, is there anything else that I should check? |
Nervous Wreck (II) Inmate From: |
![]() I'm not familiar with the "elements" member as you have it above. But the error you're getting would suggest that there is no such member for the object you've referenced. code: function fShowData(color, myElement) { alert(color); document.getElementById(myElement).value=color; window.parent.document.forms.stylesheet.elements.hex.value=color; } function fBuildTable() { var ind=0; document.write('<table id="colorTable">'); for(y=0;y<=7;y++){ document.write('<tr>'); for(x=0;x<=7;x++){ document.write('<td id="colorCell"' + 'style="background: #' + crayola[ind] + '; ' + 'color: #' + crayola[ind] + '; border: 1px solid #000000;"' + ' onClick=JavaScript:fShowData(crayola[ind],"hex")>' + ind + '</td>'); ind = ind + 1; } document.write('</tr>'); } document.write('</table>'); }
|