homepage Welcome to WebmasterWorld Guest from 54.163.91.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Image call script by using onclick
script, connect, php
GertK




msg:4621658
 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">

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




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

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

moviefactory




msg:4622805
 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




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

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




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved