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 6631955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:37:08+00:00 2026-05-25T22:37:08+00:00

Iam new @ jquery – Thats working for almost all versions of IE except

  • 0

Iam new @ jquery – Thats working for almost all versions of IE except IE9 it says “Error: ‘f’ is undefined” i didnt know why ?? and if its not recommended to giving function name like that way then what should i do ?

$(document).ready(function f(txtName) 

    {
    $("#ctl00_Content_chkBox" + txtName).click(function () 
       {
         var thisCheck = $(this);
         if  (thisCheck.is(':checked')) 
           {
             var myDate = new Date();
             var displayDate = 
                 (myDate.getMonth() + 1) + '/' + (myDate.getDate()) + '/' + myDate.getFullYear();
             $(this).next(".textbox1").val(displayDate);
           }
       });
    });

<input type="checkbox" ID="chkBoxName" runat="server"   onclick="f('Name');" />

<asp:TextBox CssClass="textbox1" PreValue="" runat="Server" ID="txt_comp_name_date_v" Required="false" Enabled="False"  />
  • 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-05-25T22:37:09+00:00Added an answer on May 25, 2026 at 10:37 pm

    You only use $(document).ready() with code that you want to run at initialization time. You do not use it for named functions that you want to run later. You look like you were trying to do some of both with the same code.

    I would suggest changing your code like this. I’ve removed the name on the function and removed the onclick=f() from your HTML that referred to it as you don’t need either. Now, there is a click handler that is run in the $(document).ready() that hooks up the click handler function for you (no need for onclick="f()" any more). The code for the click handler then carries out the rest of your work.

    $(document).ready(function() {
       $("#chkBoxName").click(function () {
         var thisCheck = $(this);
         if  (thisCheck.is(':checked')) {
           var myDate = new Date();
           var displayDate = (myDate.getMonth() + 1) + '/' + (myDate.getDate()) + '/' + myDate.getFullYear();
           thisCheck.next(".textbox1").val(displayDate);
         }
       });
    });
    
    <input type="checkbox" ID="chkBoxName" runat="server" />
    
    <asp:TextBox CssClass="textbox1" PreValue="" runat="Server" ID="txt_comp_name_date_v" Required="false" Enabled="False"  />
    

    You can see it work here: http://jsfiddle.net/jfriend00/9y7sC/.

    You should be very careful with this part of the code thisCheck.next(".textbox1") because that is very picky about finding your text field. If you put any intervening HTML tag in between the two, it won’t work – it has to be the very next HTML tag and it has to have the right class.

    If you have a lot of checkboxes next to text fields and you want them all to get this function, then just give them all the same class name and refer to that class in the jQuery code like this:

    $(document).ready(function() {
       $(".dateCheckbox").click(function () {
         var thisCheck = $(this);
         if  (thisCheck.is(':checked')) {
           var myDate = new Date();
           var displayDate = (myDate.getMonth() + 1) + '/' + (myDate.getDate()) + '/' + myDate.getFullYear();
           thisCheck.next(".textbox1").val(displayDate);
         }
       });
    });
    
    <input type="checkbox" class="dateCheckbox" runat="server" />
    
    <asp:TextBox CssClass="textbox1" PreValue="" runat="Server" ID="txt_comp_name_date_v" Required="false" Enabled="False"  />
    

    Here’s an example of multiple checkboxes working off the one piece of code: http://jsfiddle.net/jfriend00/twu5n/

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

Sidebar

Related Questions

I am new to Jquery. I am working in a form with 14 fields
I am new to JQuery.... Recently i was working on a project and i
Iam new to jquery. I have a rails form. where iam going to add/edit
I am new to jQuery and I am working with the droppable API. I
i am new to jquery, i am working on a web page which needs
I am new to jQuery.just learn and use it for 3 weeks until now.
I am new to JQuery. I'm reading JQuery in action, but only up to
I am new to jQuery. Any help would be appreciated I have two radio
I am new to jQuery and cannot get a selector to work using the
I am new to jQuery. I am having a variable increment in my code

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.