Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:59:12+00:00 2026-06-13T20:59:12+00:00

I have the following script which works fine: $(.txtDate).datepicker( { changeMonth: true, changeYear: true,

  • 0

I have the following script which works fine:

$(".txtDate").datepicker( {
    changeMonth: true,
    changeYear: true,
    yearRange: "+0:+1",
    showButtonPanel: false,
    dateFormat: "dd/mm/yy",
    onSelect: function(dateText, obj){
        test_function( dateText );
    }
} );

$('.txtDate').datepicker( "setDate" , new Date() );

function test_function( strDate ) {
    alert( strDate );
}

It datepicker enables the HTML control .txtDate, it displays todays’ date in .txtDate by default when the webpage loads, and it also displays an alert if I choose another date from the datepicker.

My question is, how do I get the datepicker to execute test_function when the page loads so it displays the default date in an alert set by the datepicker when the page loads?

The alert test_function is just a test to see when the datepicker executes other functions, the end result will be a lot more complex.

Also, I have a widget based website, which lets people add many of the same widget on the page at once, which means I will have many .txtDate controls. So I can’t just get the value of .txtDate, I will need to find the closest one based on $(this).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:59:17+00:00Added an answer on June 13, 2026 at 8:59 pm

    You try to call this test_function() function in page load, so you can able to get the datepicker default value in page load like,

    <script type="text/javascript" language="javascript">
    $(function(){
       $('.txtDate').datepicker( "setDate" , new Date() );     
       test_function();
    });
    
    function test_function() {
       alert( $("#txtDate").val() );
     }
    </script>
    

    You dont need to pass any parameter values to this js function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script which works fine: $.ajax({ url: 'serverside_script', type: 'GET', dataType:
I have the following lua script : module(modoo,package.seeall) foo=1 bar={12,34} Which works fine using
I have the following Ruby script that creates a Debian package, which works fine:
Hi I have the following script which works fine running on IIS but when
I have the following script: http://jsfiddle.net/oshirowanen/8mQ7x/1/ Which works fine, but as soon as I
I have the following script which works fine locally: <?php //Report all errors error_reporting(E_ALL);
I have written following script in python which works fine: from sys import argv
Hi all i have the following merge sql script which works fine for a
I currently have the following script: http://jsfiddle.net/oshirowanen/mnXdv/ Which works fine, i.e. if a click
I have the following script which works kind of... $(document).ready(function(){ // add or remove

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.