Click to See Complete Forum and Search --> : colorcube script


adilbookz
12-27-2002, 09:38 PM
I picked up the script for the color cube at javascriptsource.com http://javascript.internet.com/miscellaneous/color-cube.html
and have the cube on http://www.geocities.com/adilbookz/Utilities/colorcubefinished.html But for reasons that are beyond me, it doesn't work. Does anyone have any idea of what might be wrong?

bunner bob
12-30-2002, 04:23 PM
I'm trying to adapt this colorcube script to create a form field populated with the chosen color, so when the form is submitted, the chosen color is sent to a database.

It's not working.

I have this function defined:

<script language="javascript" type="text/javascript">
function SendColor(color) {
document.getElementById("headingcolordiv").innerHTML = "<input type=\"text\" name=\"headingcolor\" size=\"12\" value=\"" + color + "\">";
}
</script>

And here's the accompanying color cube and form field:

<A HREF="webpal.map"><IMG SRC="images/cube.gif" WIDTH=292 HEIGHT=196 BORDER=0 ALT="" USEMAP="#map_webpal" ISMAP></A><br>
<div ID="headingcolordiv"><input type="text" name="headingcolor" size="12" value="<?php echo $headingcolor ?>"></div>

If there's a color already in the database, the <?php echo $headingcolor ?> pulls it out of the db. This works fine. If I manually type a value into the form field it posts to the db just fine as well.

If I click on a color square in the cube, it appears to set the innerHTML properly (i.e. I can make the form field change size, and the specified color value shows up in the field) but the value does NOT get passed on "Submit". It's as if the field were empty.

Any idea what I'm missing here?

thanks!

bunner bob
12-30-2002, 06:35 PM
Well that's interesting, because I finally arrived at something that works, which is:

function SendColor(color) {
document.schemestructure.headingcolor.value = color ;
}

where the link is

<A HREF="webpal.map"><IMG SRC="images/cube.gif" WIDTH=292 HEIGHT=196 BORDER=0 ALT="" USEMAP="#map_webpal" ISMAP></A><br>
<input type="text" name="headingcolor" size="12" value="<?php echo $headingcolor ?>">

and it works just exactly like a charm.

bunner bob
12-30-2002, 07:08 PM
Oh I see - I thought you were saying I COULDN'T do document.formName.fieldName.value = "...";

I didn't see your "instead" - comes from being a "skimming" reader instead of paying better attention.

I've clearly spent too much time in front of the computer today...forgive my boobishness

adilbookz
12-31-2002, 07:10 PM
Thanks, Dave. Your suggestion worked.

adilbookz
12-31-2002, 07:35 PM
Thanks, Dave. Your suggestion worked.