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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:15:06+00:00 2026-05-28T04:15:06+00:00

I don’t like the look of normal dropdown selectors in forms, so I’ve decided

  • 0

I don’t like the look of normal dropdown selectors in forms, so I’ve decided to create my own version of them with some Jquery as a little learning project for myself.

The objective of the following code is to be able to submit the text inside the various “select” boxes, i.e. #cuisineSelect, #locationSelect and #priceSelect to “ajax.php” so that I can manipulate those variables further.

My problem is that for some strange reason ajax.php will not register the $_POST variable and it’s telling me that I’ve got an “undefined index”.

I did some debugging in IE9 with some developer tools and they show (at least I think so) that the variables are getting sent through to ajax.php, and ajax.php is returning a variable. Here are the screenshots.

IE9 Developer Tools Results - Just in case this helps.

On the real project, the user can click on the <li> options item and the text will transfer onto the selector – just like a dropdown selector.

Here is my code:

The HTML:

<div id="parentContainer" style="width:100%;">

    <div class="container"> 
        <div class="select" id="cuisineSelect">
        Cuisine
        </div>
        <div class="option" id="cuisineOption">
        <ul id="cuisineul">
            <li>Asian</li>
            <li>American</li>
            <li>Indian</li>
            <li>Fusion</li>
        </ul>
        </div>
    </div>

    <div class="container"> 
        <div class="select" id="locationSelect">
        Location
        </div>
        <div class="option" id="locationOption">
        <ul id="locationul">
            <li>Asian</li>
            <li>American</li>
            <li>Indian</li>
            <li>Fusion</li>
        </ul>
        </div>
    </div>

    <div class="container"> 
        <div class="select" id="priceSelect">
        Price
        </div>
        <div class="option" id="priceOption">
        <ul id="priceul">
            <li>Price Range</li>
            <li>Cheap ($5-$15)</li>
            <li>Medium ($16 - $20)</li>
            <li>Pricey ($21 - $35)</li>
            <li>Fine Dining ($35+)</li>
        </ul>
        </div>
    </div>

    <div class="container">
        <div class="select" id="searchButton" style="width:25px; height:20px;">
        <center><img align="center" src="images/sml_search.png" width="17" height="18" /></center>
        </div>
    </div>

</div>

<div id="result" style="z-index:10;">
result=show; 
<?php include "ajax.php"; ?>
</div>

The Jquery code (this has already been placed inside a $(document).ready function.)

$("#searchButton").click(function() { 
        /*var cuisine     = $("#cuisineSelect").html();
        var location  = $("#locationSelect").attr('value'); 
        var price     = $("#priceSelect").attr('value'); 
            $.ajax({  
                type: "POST",  
                url: "ajax.php",  
                data: "cuisine="+ cuisine +"& location="+ location +"& price="+ price,  
                success: function(){  
                    $('#result').show();  
                }  
            });  
        return false;  */

        $.post('ajax.php', 'cuisine=' + $("#cuisineSelect").text(), function () {
          $("#result").show();
       });

     });

The PHP page “ajax.php”

<?php

    //Search information
    //$cuisine = htmlspecialchars(trim($_GET['cuisine']));

    //$location = htmlspecialchars(trim($_POST['location']));
    //$price = htmlspecialchars(trim($_POST['price']));

    //echo $location;
    //echo $price;
    //$addClient  = "INSERT INTO clients (fname,lname) VALUES ('$fname','$lname')";
    //mysql_query($addClient) or die(mysql_error());

    //$value = $_POST['cuisine'];
    //$value2 = $_POST['val'];
    //echo "$value2";


    $cuisine = $_POST['cuisine'];
    echo $cuisine;

?>

Thanks very much for your help.

  • 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-28T04:15:07+00:00Added an answer on May 28, 2026 at 4:15 am
    1. There is no need to write include the ajax.php file in #result div. Keep #result div empty and hidden.
    2. Modify your ajax call as below:

      $.post('ajax.php', 'cuisine=' + $("#cuisineSelect").html(), function (data) {
            $("#result").html(data);
            $("#result").show();
        });

      This will show the clicked text in #result ‘div’. variable data is passed to callback function for further utilization.

    3. To convert the < li > to a select box, you have to pass the values present in the div #cuisineOption to ajax.php so your PHP script can create the select box from these values.

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

Sidebar

Related Questions

I don't want PHP errors to display /html, but I want them to display
For some reason, after submitting a string like this Jack’s Spindle from a text
Don't they both have to convert to machine code at some point to execute
Don't know a whole lot about streams. Why does the first version work using
Don't get me wrong, I want them to get saved. But I always thought
I don't know if this has been asked before, but what i'd like to
I don't like Jackson. I want to use ajax but with Google Gson. So
don't know if this is possible.. I'm using sqlite3 schema: CREATE TABLE docs (id
(Don't care about the version. IE or not IE.)
Don't quite understand determinism in the context of concurrency and parallelism in Haskell. Some

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.