Forum Moderators: coopster

Message Too Old, No Replies

Image call script by using onclick

script, connect, php

         

GertK

8:09 pm on Nov 6, 2013 (gmt 0)

10+ Year Member



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:

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


The:
<?=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:
<?php echo $_REQUEST["from"]; ?> 
that call the script. The script looks like:

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

JD_Toims

11:01 pm on Nov 11, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't reinvent the wheel, use jQuery instead ;)
[jqueryui.com...]

moviefactory

3:29 pm on Nov 12, 2013 (gmt 0)



Hi,

Please Try This

<img src='images/calendar.png' id="show_cal" style='cursor: pointer; vertical-align: middle;' />

<script>
$("#show_cal").click(function(){
$("#from").trigger('click');
});
</script>

JD_Toims

6:39 pm on Nov 12, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oh, you are using jQuery... lol... oops, my bad! I didn't even look at the JS, because I was in PHP mode.

I don't have time to dig through the jQuery you have right now, but I'll try to remember to come back to this one later on.

Readie

8:15 pm on Nov 13, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could alternativley look into using the CSS :after pseudo class, which if memory serves has been around long enough to not really need to worry about compatability issues with older browsers.