Need help (or an example) as I don't seems to be able to invoke jquery datepick or nicEdit when using XMLHttpRequest.
My code comes with 4 php files:
<p>Main page: main.php<br />
++++++++++++++++++<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><br />
<title>Education Centre</title><br />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" /><br />
<script type="text/javascript" src="script.js"></script><br />
<script type="text/javascript" src="mainjs.js"></script><br />
<script src="http://js.nicedit.com/nicEdit-latest.js" type='text/javascript'></script><br />
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script></p>
<p></head><br />
<body onLoad="init_table();"><br />
<div id="page"><br />
<form name='form1'><br />
<p>&nbsp;</p><br />
<div id="content"><br />
<div id="showTable"> </div><br />
</div><br />
</form><br />
</div><br />
<!-- end page --><br />
</body><br />
</html><br />
</p>
<br />
<p>mainjs.js<br />
+++++++++<br />
function init_table() {<br />
requestInfo('showMain.php?mode=list&prev_cid=1','showTable','');<br />
}</p>
<p> </p>
<p>script.js [copied and tested to be ok with other pages]<br />
+++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />
function getHTTPObject() {<br />
var xmlhttp;<br />
<br />
if(window.XMLHttpRequest){<br />
xmlhttp = new XMLHttpRequest();<br />
}<br />
else if (window.ActiveXObject){<br />
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");<br />
if (!xmlhttp){<br />
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");<br />
}<br />
<br />
}<br />
return xmlhttp;<br />
}</p>
<p>var http = getHTTPObject(); // We create the HTTP Object</p>
<p>function requestInfo(url,id,redirectPage) { <br />
var temp=new Array();<br />
http.open("GET", url, true);<br />
http.onreadystatechange = function() {<br />
if (http.readyState == 4) {<br />
if(http.status==200) {<br />
var results=http.responseText;<br />
if(redirectPage=="" || results!="1") {<br />
var temp=id.split("~"); // To display on multiple div <br />
var r=results.split("~"); // To display multiple data into the div <br />
if(temp.length>1) {<br />
for(i=0;i<temp.length;i++) { <br />
document.getElementById(temp[i]).innerHTML=r[i];<br />
}<br />
} else {<br />
document.getElementById(id).innerHTML = results;<br />
} <br />
<br />
} else {<br />
window.location.href=redirectPage; <br />
}<br />
} <br />
}<br />
};<br />
http.send(null);<br />
}<br />
</p>
<br />
<p>showMain.php<br />
++++++++++++<br />
<?php<br />
header('Content-Type: text/xml');</p>
<p>//include("config.php");<br />
//include("mysql.lib.php");<br />
//$obj=new connect;<br />
<br />
$netwkinfo = "Some information pulled from database";<br />
echo "<table>";<br />
echo "<tr><td>My Data</td> <td><textarea id='netwkinfo' cols='75' rows='5' >" . $netwkinfo . "</textarea></td></tr>";<br />
echo "</tr>";<br />
echo "</table>";<br />
?><br />
</p>
showMain.php is a file that extract data from a database to be displayed/edited etc... but for simplicity i assign a value to $netwkinfo.
What I will like to see is nicEdit feature (panel) shown at the editbox. Unfortunately I am not seeing it, just a plain edit box appears. What could be wrong and how should i correct it for it to work.
Similarly IF I used jquery datepicker on a textbox in the showmain.php, i am not seeing it work too. I think its the same concept but just couldn't figure out how to get them working.
Appreciate any help here. Thanks.
Found the hint to the answer here.
have not successfully implement nicedit yet but datepicker for jquery was resolved.
for datepicker I used:
$(function(){
$('.inputDate').live('click', function() {
$(this).datepicker({
starts: 1,
position: 'right',
onChange: function(formated, dates){
$('#inputDate').val(formated);
$('#inputDate').DatePickerHide();
}
});
});
});