BR
asked on
javascript date picker in php while loop
Dear Experts,
I have a date picker, it is works like input type= date
it works however, when I use it in a loop, it only works on the first row.
Although it has the same id, and very same code, it doesn't work on the other rows.
I have 250 rows, but the date picker works only at the first row.
I echo this in the while loop
I have a date picker, it is works like input type= date
it works however, when I use it in a loop, it only works on the first row.
Although it has the same id, and very same code, it doesn't work on the other rows.
I have 250 rows, but the date picker works only at the first row.
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
I echo this in the while loop
"<input type=text id='datepicker' name=cekilecektarih style=width:70px; />";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Shaun Vermaak
In HTML and CSS, the id attribute must be unique. The class attribute can name several elements. Your id and class attributes can be collections of CSS selector names, such as class="datepicker urgent action". This is what empowers the "cascade" of styles.
In jQuery, the selector starts with # if you want to select by id and starts with . (dot) if you want to select all elements of a matching class.
The W3Schools has good documentation about this!
http://www.w3schools.com/css/css_intro.asp
In jQuery, the selector starts with # if you want to select by id and starts with . (dot) if you want to select all elements of a matching class.
The W3Schools has good documentation about this!
http://www.w3schools.com/css/css_intro.asp
ASKER
Thank you Ray Pasuer,
Open in new window
you probably need to put a unique id for your each datepicker, like :Open in new window
when you call the function, try to include that id into your function