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

  • Home
  • SEARCH
  • 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 8555273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:05:13+00:00 2026-06-11T15:05:13+00:00

I’m trying to implement Ajax jQuery Form submission. The code I pasted below is

  • 0

I’m trying to implement Ajax jQuery Form submission. The code I pasted below is not working. I get an undefined index error for day month and year

jQuery Ajax

<script>
 $(document).ready(function() {
    $('#cal_submit').click(function(event) { 
      if ($('select[name="day"]').val() == '') {
            event.preventDefault();
            alert('Please enter a day');
        }
        else {
            event.preventDefault();
            new_day = $('select[name="day"]').val();
            new_month = $('select[name="month"]').val();
            new_year = $('select[name="year"]').val();
            $.get('function.php', { day: new_day, month: new_month, year:new_year} );
            $('select[name="day"]').val('');
            $('select[name="month"]').val('');
            $('select[name="year"]').val('');
        }
    }); 
});
</script>

The function where the handling php is located.

function calendar()
{ 


        $j = mysql_real_escape_string($_GET['day']);
        $F = ucwords(mysql_real_escape_string($_GET['month']));
        $Y = mysql_real_escape_string($_GET['year']);
        $date =" ".$F." ".$j.", ".$Y." ";

   $query = "SELECT * 
              FROM calendar 
              WHERE event_day = '".$j."'
              AND   event_month = '".$F."'
              AND   event_year  = '".$Y."'" ; 
            $run = mysql_query($query);
            $norows = mysql_numrows($run);

            if ($norows < 1){
                echo "<div class=\"indexnoresult\">No TAP Event(s) for $date</div>" ;
            }  else {
            while($row = mysql_fetch_array($run)) {

                  echo "<div class=\"indexnoresult\">Event(s) for $date<br>
                   Name :   $row[event_name]  <br>
                   Time :   $row[event_time]   <br> 
                   Venue :  $row[event_venue]  <br>
                  </div> 
                 " ;



            }

            } ?>

HTML Form

     <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" >

                Pick Date To View Events     

             <select name="day">
                    <option value ="">    </option>
                    <option value ="1">1</option>
                    <option value ="2">2</option>   
             </select> 

    Month
                <select name="month">
                    <option value ="">    </option>
                    <option value ="january">January</option>
                    <option value ="february"> february </option>
                    <option value ="march">March</option>
                 </select>

    Year:
                 <select name="year">
                    <option value ="">    </option>
                    <option value ="2005">2005</option>
                    <option value ="2006">2006</option>             
               </select>

    <input type='submit' name='cal_submit' id='cal_submit'>
    </form>
    </div> 

Please where I’m I going wrong.

  • 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-11T15:05:14+00:00Added an answer on June 11, 2026 at 3:05 pm

    you need to have the same variable in your ajax object/data.

            day = $('select[name="day"]').val();
            month = $('select[name="month"]').val();
            year = $('select[name="year"]').val();
            $.get('function.php', { day: day, month: month, year:year} );
    

    the first select option (default value when ajax is called, without making a selection from the select list) is blank, thats why the error.

    also, the form says POST method whereas your ajax is GET.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to select an H1 element which is the second-child in its group

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.