Jump to content

jquery datepicker passing variable


phpfreakjav

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.