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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:33:29+00:00 2026-06-06T05:33:29+00:00

I am building a form using a js+html and I ran into a problem.

  • 0

I am building a form using a js+html and I ran into a problem. There’s a part of my form where user should be able to click on a textfield and pick a date & time from a calendar(anytime.js by MAM3), and since my form(partial code) is built this way:

third_list = "<table class='table'>";
if (radio_array[genIndex] == reserve) {
    third_list += "<tr><td id='Date:'><label><span id='Date'>Date:</span><input type='text' id='Date' name='_date' size='20' onfocus='showMessage()'/></label></td>";
    third_list += "<td id='Time:'><label><span id='Time'>Time:</span><input type='text' id='Time' name='_time' size='20' /></label></td>";
    document.getElementById("third").innerHTML = third_list;
    l3_value = "";
    return;
}

and by putting this to the html:

    <script type="text/javascript">
    AnyTime.widget
        ( "Date",
            { format: "%m/%d/%Z" }
        );
    AnyTime.widget
        ( "Time",
            { format: "%h:%i:%p" }
        );
    </script>

it does not pop-up a calendar.

Side notes: I have included all of the required js&css files and tried to see if it works on a seperate text field out from js, and it works. I think the reason it doesnt work is it is controlled by js, so the anytime.js does not see it as a html name field.

SN2: onfocus=’showMessage()’ in my js is to show a message when a user clicks on a text field.

How do I make it work?

  • 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-06T05:33:31+00:00Added an answer on June 6, 2026 at 5:33 am

    A couple of issues:

    First, you have more than one element with the id values Date and Time. id values must be unique in the document. I expect the script isn’t getting the element it expects and is failing to init. The documentation for AnyTime seems to suggest it uses the first argument you give AnyTime.widget as an id and expects to get an input field. In your case, it usually won’t on most browsers, because when faced with an invalid structure featuring duplicate ids, most browsers will return the first one when you ask for “the” element with that id, which in your case is a span rather than an input field.

    Your Date elements:

    <span id='Date'>Date:</span><input type='text' id='Date' ... />
    <!--      ^--- one                                 ^--- two -->
    

    The Time is the same sort of problem.

    Separately from that, I suspect you need to ensure that the elements exist when you call AnyTime.widget. I don’t know where you have that script tag that calls it, but what you need to do is make this calls after you’ve executed the line

    document.getElementById("third").innerHTML = third_list;
    

    …so that the elements in question exist in the DOM. So for instance:

    third_list = "<table class='table'>";
    if (radio_array[genIndex] == reserve) {
        third_list += "<tr><td id='Date:'><label><span id='Date'>Date:</span><input type='text' id='Date' name='_date' size='20' onfocus='showMessage()'/></label></td>";
        third_list += "<td id='Time:'><label><span id='Time'>Time:</span><input type='text' id='Time' name='_time' size='20' /></label></td>";
        document.getElementById("third").innerHTML = third_list;
        l3_value = "";
        setUpWidgets();
        return;
    }
    
    // ...elsewhere in the same scope or a containing scope:
    function setUpWidgets() {
        AnyTime.widget
            ( "Date",
                { format: "%m/%d/%Z" }
            );
        AnyTime.widget
            ( "Time",
                { format: "%h:%i:%p" }
            );
    }
    

    That creates a function, which you call when the elements are there.


    Side note: You also have an id that looks like this:

     <td id='Date:'>
    

    Although that’s a valid id in HTML5, it wasn’t valid in HTML4 and isn’t valid in CSS. So if you try to use that id in a CSS-style selector (for instance, with jQuery), you’ll probably run into trouble.

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

Sidebar

Related Questions

im building a file upload/dwnload app in php..im using the following form <html> <head>
I'm building a dynamic drop down box for an HTML form using PHP and
I am building an order form using HTML and jQuery and it is complete,
I am using an html sign up form for a website I'm building. The
I am building a simple user registration form using the MVC design pattern, in
I'm currently building a web form using APEX that is losely modelled after a
Am building window form application for a clinic using VS2010. On the form in
I am building a form in Zend Framework 1.9 using subforms as well as
I've recently begun working on a project regarding GUI building using some form of
I'm building a WinForms application Window (form), inside that I'm using a FlowLayoutPanel, with

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.