i have select box, on selectinga value in have display form in there date field include javascript calendar functionalty. tried normal ajax , php combination, dont calendar in it, need know how can make happen using json , ajax , php?
thanks
every appreciated....
the code
this javascript using ajax function:
<script> function inint_ajax() { try { return new activexobject("msxml2.xmlhttp"); } catch(e) {} //ie try { return new activexobject("microsoft.xmlhttp"); } catch(e) {} //ie try { return new xmlhttprequest(); } catch(e) {} //native javascript alert("xmlhttprequest not supported"); return null; }; function dochange(path,val) { var req = inint_ajax(); req.onreadystatechange = function () { if (req.readystate==4) { if (req.status==200) { document.getelementbyid('docfields').innerhtml=""; if(req.responsetext != ''){ document.getelementbyid('docfields').innerhtml=req.responsetext; //retuen value }else{ document.getelementbyid('docfields').innerhtml="<br> \t<font size='2'><b>no fields available</b></font>"; } } } }; req.open("get", path+"getdocfields.php?doctype_id="+val); //make connection req.setrequestheader("content-type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set header req.send(null); //send value } </script>
below html form need display calendar object (tcal) instantiated in script tag:
<form onsubmit="" action="" method="post" name="newdoc"> <table border="0" style="border: medium none;" id="docfield"> <tbody> <tr> <td style="border-right: medium none;"> date </td> <td style="border-right: medium none;"> <input type="text" value="" maxlength="10" name="test" style="width: 100px;" id="date"> <script> new tcal ({ 'formname': 'newdoc', 'controlname': 'test' }); </script> </td> </tr> </tbody> </table> </form>
i not getting calendar displayed...
i see javascrip in response html, never executed if html coming through ajax call. try put javascript
new tcal ({ 'formname': 'newdoc', 'controlname': 'test' });
after xmlhttprequest object fetches , puts data in '#docfields'.
if (req.readystate==4) { if (req.status==200) { document.getelementbyid('docfields').innerhtml=""; if(req.responsetext != '') { document.getelementbyid('docfields').innerhtml=req.responsetext; //retuen value /** here **/ new tcal ({'formname': 'newdoc','controlname': 'test'}); /** here **/ } else { document.getelementbyid('docfields').innerhtml="no fields available"; } } }
hope help.
Comments
Post a Comment