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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:40:38+00:00 2026-06-01T00:40:38+00:00

How can I do this in Javascript/jQuery from PHP? I am trying to populate

  • 0

How can I do this in Javascript/jQuery from PHP? I am trying to populate a select list from a start date up to 6 months in advance.

    $startDate =  intval( $c->getStartDate($pid) );
    $endDate =  strtotime('+6 month', $startDate);
    $dateSelectList = '<select name="dateSelect" id="dateSelect">';
    $count = 1;
    //populates the select list with the starting date of the course up to the next six months
    for($date = $startDate; $date <= $endDate ; $date = strtotime('+1 day', $date))
    {
        $dateSelectList .= '<option id="select'.$count.'" value="'.$date.'">'.date('D d F Y', $date).'</option>';
        $count++;
    }

    $dateSelectList .= '</select>';
  • 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-01T00:40:39+00:00Added an answer on June 1, 2026 at 12:40 am

    One way you can do this is to use ajax with jQuery. So first step is to modify your code to:

    $startDate =  intval( $c->getStartDate($pid) );
    $endDate =  strtotime('+6 month', $startDate);
    $dateSelectList = '';
    $count = 1;
    //populates the select list with the starting date of the course up to the next six months
    for($date = $startDate; $date <= $endDate ; $date = strtotime('+1 day', $date))
    {
        $dateSelectList .= '<option id="select'.$count.'" value="'.$date.'">'.date('D d F Y', $date).'</option>';
        $count++;
    }
    
    echo $dataSelectList;
    

    then save into a separate file say populate.php

    Then on the html page you write the following code. Code assumes you have included jquery to your page and that you have a select element with id = dateSelect

    <script>
    $(function(){
       $.get('populate.php',function(data)
       {
           $('#dateSelect').html(data);
       }
    });
    </script>
    

    The above code calls populate.php on load of the page, which returns all the options and injects it into the select element

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

Sidebar

Related Questions

I'm trying to figure out how I can pass data from page-list.php to page.php
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
I can bind a jquery event to this element like: <script type=text/javascript> $('#new_key').ready(function() {
I'm trying to find out how I can force elements to start from the
I am trying to get a Ajax-call made from jQuery to return a JavaScript
im trying to figure out how i can do this. i have a list
Can anyone explain how to run PHP code from within javaScript for submit? Currently
Hi i'm trying to retrieve response after passing some variables from javascript to php
I am trying to use jquery ajax to get data from a php file.
I'm trying to produce a multiple select list with selected options based from a

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.