Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Image call script by using onclick

script, connect, php

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

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">

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:

$(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 ||
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );

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?
11:01 pm on Nov 11, 2013 (gmt 0)

WebmasterWorld Senior Member Top Contributors Of The Month

Don't reinvent the wheel, use jQuery instead ;)
3:29 pm on Nov 12, 2013 (gmt 0)


Please Try This

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

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

WebmasterWorld Senior 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.
8:15 pm on Nov 13, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ 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.

Featured Threads

Hot Threads This Week

Hot Threads This Month