Click only run once
Click only run once
Hi everyone. I am currently developing a Color-picker for a forum.
This is how it will look:
On the right side you select hue, and then you select saturation and value in the remaining fields. Everytime you click one of the right boxes the table is supposed to update with the new colorscheme. The problem is that it only works once.
This is the code for the picker. I have not included the libraries with the color converting functions becouse I do not think the problem lies there.
-
<html>
<head>
<script language="javascript" src="jquery/dist/jquery.js"></script>
<script language="javascript" src="picker.js"></script>
<link href="picker.css" rel="stylesheet" type="text/css" />
<script language="javascript">
/*
This ColorPicker was created by
Duncan Entertainment
*/
$(document).ready
(
function()
{
$("#picker").html(updateTable(0));
function updateTable(colorValue)
{
var finaltext = "";
for(var i = 9; i >= 0; i--)
{
finaltext += "<tr>\n";
for(var j = 0; j < 11; j++)
{
if(j == 10)
{
var c = rgbToHex(hsvGetRed(i, 10, 10)) +
rgbToHex(hsvGetGreen(i, 10, 10)) +
rgbToHex(hsvGetBlue(i, 10, 10));
finaltext += '<td bgcolor="#' + c + '"><a class="value" id="' + i + '"><div class="inside"></div></a></td>\n';
}
else
{
var c = rgbToHex(hsvGetRed(colorValue, i, j)) +
rgbToHex(hsvGetGreen(colorValue, i, j)) +
rgbToHex(hsvGetBlue(colorValue, i, j));
finaltext += '<td bgcolor="#' + c + '"><a class="palette" bgcolor="#' + c + '"><div class="inside"></div></a></td>\n';
}
}
finaltext += "</tr>\n";
}
return(finaltext);
}
$(".value").click
(
function()
{
alert(this.id);
$("#picker").html(updateTable(this.id));
}
);
}
);
</script>
<title>Color Picker</title>
</head>
<body>
<table id="picker"></table>
</body>
</html>
Does anyone know why it only run once?
If you want to test it yourself then here is a .zip with all the files included:
http://jhu0xw.blu.livefilestore.com/y1pGmKffxRZZibegVnG8Fs3MGAGbdB4k_qdvWOaz1-RlzC3rHVfRkAcx-Dp7LN8rWrF3cGCsRd86qez6ZEGEeetD0Ve1YSn311m/ColorPicker.zip?download