Page 1 of 1

Image call script by using onclick

Posted: Wed Nov 06, 2013 2:14 pm
by GertK
I have a form where you have to inset a date.Im using a script that can auto fill the form with a choosen date.

The form looks like this:

Code: Select all

<input type="text" value="<?=date('Ymd');?>" id="from" id="<?php echo $_REQUEST["from"]; ?>" name="displaydate">
The:

Code: Select all

<?=date('Ymd');?> 
just show the date of today. If you want to use anyother date you can click on the form and a "drop-down" calendar is showed. Its the code:

Code: Select all

<?php echo $_REQUEST["from"]; ?>
that call the script. The script looks like:

Code: Select all

<script>
	$(function() {
		var dates = $( "#from, #to" ).datepicker({
			changeMonth: true,
			numberOfMonths: 2,
			dateFormat: 'yy-mm-dd',
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
	});
	</script>


Now what I need help to, is that I would like to place a small calendar image beside the form. When you click the small image the calendar also "drop-down" just as when you click on the form. I have tried with the code:

Code: Select all

<img src='images/calendar.png' onclick="from" style='cursor: pointer; vertical-align: middle;' />
but that dont help. Any suggestions?