We are currently utilizing the JavaScript Color picker from without any issues. However, we have encountered a problem when generating the input element via AJAX. The jscolor.js script is unable to detect the class (color) of the input even though the input appears correctly on the page. What steps should we take to resolve this issue?
The HTML code snippet in question is as follows:
<html>
<head>
<script src='/js/jscloro.js'></script>
<script>
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","gethint.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<a href="#" onClick="showHint('jscolorpicker')">FORM</a>
<div id="txtHint"></div>
</body>
</html>
Our PHP response to the AJAX request includes the following line:
echo "<input class=\"color\" type=\"text\" value=\"66ff00\">";