0

Hello,

I need to show the date picker in an input field that is inside a form. I have index.php which has the code for the date picker, I just need to link it to the input field. I have the form in another file as follows:

<form id="inputArea" action="index.php?action=login" method="post">
<input type="text" name="datepicker" value="<?php echo $array['date'];?>"/>
<label for="date">Date of Birth (mm-dd-yyy):</label>
</form>

the code for the datepicker in index.php is:

<script type="text/javascript">

$(document).ready(function() {

	var $datepicker = $( '#datepicker' );

		$datepicker.datepicker({
			
			changeMonth: true,
			changeYear: true
		});
	});
	
	</script>

Thsnks

Edited by rse: code is not right

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by rse
0

Hi,

It's not working because your selector doesn't exist:

$('#datepicker'); // This means an element with id="datepicker"
$('input[name=datepicker]');  // This means an input element with name="datepicker"

To resolve, change your selector, or add an id attribute of datepicker to your input field.

R.

0

Thank you very much the second one worked for me.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.