phpfreakjav Posted April 21, 2009 Share Posted April 21, 2009 using jquery u can easily create a calendar with this code. see example here:http://jqueryui.com/demos/datepicker/default.html <script type="text/javascript"> $(function() { $("#Date0").datepicker(); $("#Date1").datepicker(); $("#Date2").datepicker(); }); <input name="Date0" id="Date0" /> <input name="Date0" id="Date1" /> <input name="Date0" id="Date2" /> this is crystal clear to me. Now my problem is the following. I need a way to automatically assign the function from jquery to each <tr> created by the php file any suggestions. This is what I have tried: I created a php script that reads a note pad file with delimiter |. The php script creates a table automatically until all fields are read. Each <input> has its unique id. I have done this so far in javascript. function numrows() { var date="Date"; //the following statement will count how many rows in the table with id test. var rowCount = document.getElementById("test").getElementsByTagName("tr").length; rowCount=rowCount-1;// the number of rows minus the table header <th></th> alert(rowCount); for (var i=0; i<=rowCount; i++) { date=date +i; alert(date);//shows that proper id's are being iterated. $(function() { $(date).datepicker(); //HERE IS MY PROBLEM! ( this is the jquery library file)How do I //I send the variable date } ); date="Date";//resets the date but not the counter i } } </script> Link to comment https://forums.phpfreaks.com/topic/154998-jquery-datepicker-passing-variable/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.