php - Using jscript / jquery in a div -


i’m trying use jscript/ jquery in div have been unsuccessful. example, code below file1.php, file2.php datepicker on both files work independently, when file2.php brought div on file1.php, datepicker file2.php inside div not work. on native file1.php does. suggestions?

update!!! found solution. here’s code…

<html> <link rel="stylesheet" href="../datepicker/jquery-ui.css">  <script type="text/jscript" src="../datepicker/jquery-1.8.3.js"></script> <script type="text/jscript" src="../datepicker/jquery-ui.js"></script> <script type="text/jscript"> $(function() { $( "#datepicker1" ).datepicker(); }); </script> <script type="text/jscript"> function autosubmit() { $.post('file2.php', $('form[name="report"]').serialize(), function (output) { $('#info').html(output).show(); $('#info').find('#datepicker2').datepicker(); }); } </script> <head> <form name="report" action="submit.php" method="post"> <select name="select1" onchange="autosubmit();"> <option></option> <option value="value1">value1</option> <option value="vaule2">vaule2</option> </select> </form> file 1 date picker<input name="date" id="datepicker1" value="<?php echo date("n/j/y");?>"> <div id="info"></div> 

file2.php code.

file 2 date picker <input name="date" id="datepicker2" value="<?php echo date("n/j/y");?>"> 

since contents of file2 loaded using post command widgets inside file2 has initialized after dom loaded content.

from understood have input field id datepicker1 in file1 , file2, invalid because element id should unique in document, recommend adding class called data-picker file2 input field. try

function autosubmit() {     $.post('file2.php', $('form[name="report"]').serialize(), function (output) {         $('#info').html(output).show();          $('#info').find('.date-picker').datepicker();     }); } 

update:

if following script present in file2 then

$(function() { $( "#datepicker1" ).datepicker(); }); 

you need move script bottom of page, ie after input element added , change id unique value


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -