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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:20:04+00:00 2026-06-10T10:20:04+00:00

I am using this function as a calender drop down menu. I am not

  • 0

I am using this function as a calender drop down menu. I am not sure how to write the php <inputtype ="text" ...

This is the php function to generate the drop down . How do i write the <inputtype="text" statement ?

Sorry I am new to PHP and I can not figure out how to do this ?

<?PHP 

    FUNCTION DateSelector($inName, $useDate=0) 
    { 
        /* create array so we can name months */ 
        $monthName = ARRAY(1=> "January", "February", "March", 
            "April", "May", "June", "July", "August", 
            "September", "October", "November", "December"); 

        /* if date invalid or not supplied, use current time */ 
        IF($useDate == 0) 
        { 
            $useDate = TIME(); 
        } 

        /* make month selector */ 
        ECHO "<SELECT NAME=" . $inName . "Month>\n"; 
        FOR($currentMonth = 1; $currentMonth <= 12; $currentMonth++) 
        { 
            ECHO "<OPTION VALUE=\""; 
            ECHO INTVAL($currentMonth); 
            ECHO "\""; 
            IF(INTVAL(DATE( "m", $useDate))==$currentMonth) 
            { 
                ECHO " SELECTED"; 
            } 
            ECHO ">" . $monthName[$currentMonth] . "\n"; 
        } 
        ECHO "</SELECT>"; 

        /* make day selector */ 
        ECHO "<SELECT NAME=" . $inName . "Day>\n"; 
        FOR($currentDay=1; $currentDay <= 31; $currentDay++) 
        { 
            ECHO "<OPTION VALUE=\"$currentDay\""; 
            IF(INTVAL(DATE( "d", $useDate))==$currentDay) 
            { 
                ECHO " SELECTED"; 
            } 
            ECHO ">$currentDay\n"; 
        } 
        ECHO "</SELECT>"; 

        /* make year selector */ 
        ECHO "<SELECT NAME=" . $inName . "Year>\n"; 
        $startYear = DATE( "Y", $useDate); 
        FOR($currentYear = $startYear - 5; $currentYear <= $startYear+5;$currentYear++) 
        { 
            ECHO "<OPTION VALUE=\"$currentYear\""; 
            IF(DATE( "Y", $useDate)==$currentYear) 
            { 
                ECHO " SELECTED"; 
            } 
            ECHO ">$currentYear\n"; 
        } 
        ECHO "</SELECT>"; 

    } 
?> 

<HTML> 
<BODY> 
<FORM> 
Choose a Date: <?PHP DateSelector( "Sample"); ?> 
</FORM> 
</BODY> 
</HTML>

The end of my code .

Thank you in advance . Sorry I am new to PHP

  • 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-10T10:20:05+00:00Added an answer on June 10, 2026 at 10:20 am

    There is no need to add a text box for the date. You can just set them by concatenating the posted values

    $selected_date = $_POST['SampleYear'] . $_POST['SampleMonth'] . $_POST['SampleDay']; 
    

    —

    If you feel it necessary to have a <input type="text" /> with the date, you can do this using jQuery

    // in the head of your document
      //this checks for when elements of date are changed
    $(function() {
    $('#SampleMonth').change(function(){ setSelectedDate();});
    $('#SampleDay').change(function(){ setSelectedDate();});
    $('#SampleYear').change(function(){ setSelectedDate();});
    }
      // this changes the text box to the values of the selects
    Function setSelectedDate(){
    var sel_month = $('#SampleMonth').val();
    var sel_day = $('#SampleDay').val();
    var sel_year = $('#SampleYear').val();
    var new_sel_date = sel_year + "-" + sel_month + "-" + sel_day;
      // note that this puts the date as YYYY-MM-DD, which is the proper way to insert into mysql. It can be set as MM/DD/YYYY, but then you would have to change it again after posting.
    $('#purchasedate').val(new_sel_date);
    }
    
    // inside the form tags
    <input type="text" id="purchasedate" name="invoice_date" value="" readonly="true" />
    

    Then you can input it in via the posted value

    $selected_date = $_POST['purchasedate'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this function to get the featured images: <a href=# rel=prettyPhoto> <?php
I am using this function but it is not working. I'm using StoryBoard and
I am using this function https://www.php.net/sys_getloadavg to get a hint about my server load.
I am not sure if I am using this correctly so my problem may
I am using this function try to make a request to the server. I
I am using this function (that I found on this forum) to calculate the
I am using this function to list items from table helps depending on parameters:
I am using this function to redirect to a random post. I am trying
Hi am using this function that works by a single ID ( 52000121 )
I am using this function to close existing form and open a new form.

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.