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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:46:15+00:00 2026-05-23T16:46:15+00:00

I want to set date in Schedule header by putting div id from Calendar

  • 0

I want to set date in Schedule header by putting div id from Calendar Creation function to Header text.

I get id like this $('.dayNumberCellValue').attr('id');, but I have a problem that when you tap on day in calendar, I get the same date to all days, “27” (this is the startDate of my calendar). It seems to me that in $('.dayNumberCellValue').attr('id'); goes the same date, but why, and how the calendar is working fine if he must show only the “27” date in all cells?

Tap function->>

        $('.div-cell').tap(function() {
                            var i;
                            var myDate2;
                              for (i = 0; i < 42; i++) {
                                $('#' + i + 'dayCell').removeClass('tapped');

                                      }

                              $(this).toggleClass(
                                   'tapped');

                              if($(this).hasClass('tapped')){


                                    myDate2 = $('.dayNumberCellValue').attr('id');
                                    $('#MSchedule header h4').text("S - "+myDate2);}

                    });

Calendar creation->

function setCalendar() {

    var cTime = new Date();
    var myDate = months[cTime.getMonth()] + " " + cTime.getFullYear();
    var myDate2 = cTime.getDate() + " " + months[cTime.getMonth()];


    $('#MCalendar header h4').text(myDate);
     $('#MSchedule header h4').text("Schedule  -  " + myDate2)

    var monthView = new Array(42);

    var firstDayOfMonth = new Date(cTime.getFullYear(), cTime.getMonth(), 1);

    while (firstDayOfMonth.getDay() != 1) {

        firstDayOfMonth.addDays(-1);

    }

    var i;

    for (i = 0; i < monthView.length; i++) {


        startDate = new Date(firstDayOfMonth);

        monthView[i] = startDate.addDays(i);

        }


for(var day=0;day<monthView.length;day++){

var needDay=monthView[day].getDate();

var cell = $('#'+day+'dayCell');
var content = '<div class="dayNumberCellValue" id=' +needDay+ '>'
    + monthView[day].getDate()
            + '</div>';
        cell.append(content);}
  • 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-23T16:46:15+00:00Added an answer on May 23, 2026 at 4:46 pm

    This line:

    myDate2 = $('.dayNumberCellValue').attr('id');
    

    will always get the id value of the first matching element (the first element with the class “dayNumberCellValue” in the document, starting at the top).

    You haven’t shown your markup, but if the element you want is inside the tapped element, then within your tap handler you can find it like this:

    myDate2 = $(this).find('.dayNumberCellValue').attr('id');
    

    That looks for the first “dayNumberCellValue” element within the this element, which on tap will be the element you’re watching the tap event on.


    Off-topic: You’ve said you’re always getting “27”, which suggests you’re using “27” as the id of an element. While that’s recently been allowed (by HTML5), it was invalid in HTML 4 and earlier, and remains invalid in CSS. I would recommend not using an ID starting with a digit. In fact, I think I’d probably use a data-* attribute to store the date rather than id.

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

Sidebar

Related Questions

I want to display result set of Years between From date - To date
How To Set DatePreference Default Value From Java Side. I Want Set to Date
Hello All I want to create a dialog from which I can set date
In my Application i want to set the Different alarm on defferent date. So
I have a DATE datatype mysql column in a table. I want to set
I have a record set that includes a date field, and want to determine
i have a problem, i want set text of a UILabel or UItextView or
I want to normalize date fields from an old badly designed db dump. I
Is there any way I can set Cookie expiration date from other page -
Hi I want to set min date in my jQuery datepicker to (1999-10-25). So

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.