How to Fetch results from server using JQuery AJAX? on the basis of Drop-down Condition The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to structure Ajax module/widgetdisplay timer countdown according to attribute valueHow to redirect particular page based on selected dropdown optionsHow can I use AJAX in magento for retrieve data when change the drop-down?Magento price slider not workingHow to convert Magento 2 Sort By Dropdown to Horizontal ListChange value of text field in admin form based on option selected in dropdownPopulate sub category drop down based on category selected magento2Fetch all the students on the basis of ascending marksMagento 2 - The right way to get a product attribute value

One-dimensional Japanese puzzle

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

Pretty sure I'm over complicating my loops but unsure how to simplify

Simulating Exploding Dice

How do you keep chess fun when your opponent constantly beats you?

Deal with toxic manager when you can't quit

Am I ethically obligated to go into work on an off day if the reason is sudden?

Do I have Disadvantage attacking with an off-hand weapon?

Can we generate random numbers using irrational numbers like π and e?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

What other Star Trek series did the main TNG cast show up in?

Would an alien lifeform be able to achieve space travel if lacking in vision?

Word for: a synonym with a positive connotation?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Circular reasoning in L'Hopital's rule

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Make it rain characters

Mortgage adviser recommends a longer term than necessary combined with overpayments

How to determine omitted units in a publication

What is the padding with red substance inside of steak packaging?

What aspect of planet earth must be changed to prevent the industrial revolution?

What happens to a Warlock's expended Spell Slots when they gain a Level?

For what reasons would an animal species NOT cross a *horizontal* land bridge?



How to Fetch results from server using JQuery AJAX? on the basis of Drop-down Condition



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to structure Ajax module/widgetdisplay timer countdown according to attribute valueHow to redirect particular page based on selected dropdown optionsHow can I use AJAX in magento for retrieve data when change the drop-down?Magento price slider not workingHow to convert Magento 2 Sort By Dropdown to Horizontal ListChange value of text field in admin form based on option selected in dropdownPopulate sub category drop down based on category selected magento2Fetch all the students on the basis of ascending marksMagento 2 - The right way to get a product attribute value



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have two conditions, if two conditions are matching the given value should display. I am using input value as Drop down. If the value of two drop-downs matched i need to display my value on same page.
For Example:
dropDown1 selection -> KM : 10(Dropdown),
dropDown1 selection -> Fueal : 2 Lit(Dropdown)



Output: Happy Jorney
On the same page and below the drop-down List.










share|improve this question
























  • if you need a condition within ajax functionality (or) before ajax functionality

    – divya sekar
    Apr 9 at 5:05











  • @divyasekar If two drop-down select and if it is matching the value should be display below like i.stack.imgur.com/Kg9pA.png

    – zus
    Apr 9 at 5:19











  • You are are confusing using word Ajax. its on page JS give me few minutes I will let you know.

    – Hassan Ali Shahzad
    Apr 9 at 5:21











  • @HassanAliShahzad Let me explain, i need the the value should be display without click or refresh the page, so that i need AJAX,

    – zus
    Apr 9 at 5:23











  • ok now its second part after selection from where you will get result ? on the basis of two matched sections.

    – Hassan Ali Shahzad
    Apr 9 at 5:25


















0















I have two conditions, if two conditions are matching the given value should display. I am using input value as Drop down. If the value of two drop-downs matched i need to display my value on same page.
For Example:
dropDown1 selection -> KM : 10(Dropdown),
dropDown1 selection -> Fueal : 2 Lit(Dropdown)



Output: Happy Jorney
On the same page and below the drop-down List.










share|improve this question
























  • if you need a condition within ajax functionality (or) before ajax functionality

    – divya sekar
    Apr 9 at 5:05











  • @divyasekar If two drop-down select and if it is matching the value should be display below like i.stack.imgur.com/Kg9pA.png

    – zus
    Apr 9 at 5:19











  • You are are confusing using word Ajax. its on page JS give me few minutes I will let you know.

    – Hassan Ali Shahzad
    Apr 9 at 5:21











  • @HassanAliShahzad Let me explain, i need the the value should be display without click or refresh the page, so that i need AJAX,

    – zus
    Apr 9 at 5:23











  • ok now its second part after selection from where you will get result ? on the basis of two matched sections.

    – Hassan Ali Shahzad
    Apr 9 at 5:25














0












0








0


1






I have two conditions, if two conditions are matching the given value should display. I am using input value as Drop down. If the value of two drop-downs matched i need to display my value on same page.
For Example:
dropDown1 selection -> KM : 10(Dropdown),
dropDown1 selection -> Fueal : 2 Lit(Dropdown)



Output: Happy Jorney
On the same page and below the drop-down List.










share|improve this question
















I have two conditions, if two conditions are matching the given value should display. I am using input value as Drop down. If the value of two drop-downs matched i need to display my value on same page.
For Example:
dropDown1 selection -> KM : 10(Dropdown),
dropDown1 selection -> Fueal : 2 Lit(Dropdown)



Output: Happy Jorney
On the same page and below the drop-down List.







ajax php-7 dropdown-options






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 9 at 6:25









Hassan Ali Shahzad

734317




734317










asked Apr 9 at 4:54









zuszus

87119




87119












  • if you need a condition within ajax functionality (or) before ajax functionality

    – divya sekar
    Apr 9 at 5:05











  • @divyasekar If two drop-down select and if it is matching the value should be display below like i.stack.imgur.com/Kg9pA.png

    – zus
    Apr 9 at 5:19











  • You are are confusing using word Ajax. its on page JS give me few minutes I will let you know.

    – Hassan Ali Shahzad
    Apr 9 at 5:21











  • @HassanAliShahzad Let me explain, i need the the value should be display without click or refresh the page, so that i need AJAX,

    – zus
    Apr 9 at 5:23











  • ok now its second part after selection from where you will get result ? on the basis of two matched sections.

    – Hassan Ali Shahzad
    Apr 9 at 5:25


















  • if you need a condition within ajax functionality (or) before ajax functionality

    – divya sekar
    Apr 9 at 5:05











  • @divyasekar If two drop-down select and if it is matching the value should be display below like i.stack.imgur.com/Kg9pA.png

    – zus
    Apr 9 at 5:19











  • You are are confusing using word Ajax. its on page JS give me few minutes I will let you know.

    – Hassan Ali Shahzad
    Apr 9 at 5:21











  • @HassanAliShahzad Let me explain, i need the the value should be display without click or refresh the page, so that i need AJAX,

    – zus
    Apr 9 at 5:23











  • ok now its second part after selection from where you will get result ? on the basis of two matched sections.

    – Hassan Ali Shahzad
    Apr 9 at 5:25

















if you need a condition within ajax functionality (or) before ajax functionality

– divya sekar
Apr 9 at 5:05





if you need a condition within ajax functionality (or) before ajax functionality

– divya sekar
Apr 9 at 5:05













@divyasekar If two drop-down select and if it is matching the value should be display below like i.stack.imgur.com/Kg9pA.png

– zus
Apr 9 at 5:19





@divyasekar If two drop-down select and if it is matching the value should be display below like i.stack.imgur.com/Kg9pA.png

– zus
Apr 9 at 5:19













You are are confusing using word Ajax. its on page JS give me few minutes I will let you know.

– Hassan Ali Shahzad
Apr 9 at 5:21





You are are confusing using word Ajax. its on page JS give me few minutes I will let you know.

– Hassan Ali Shahzad
Apr 9 at 5:21













@HassanAliShahzad Let me explain, i need the the value should be display without click or refresh the page, so that i need AJAX,

– zus
Apr 9 at 5:23





@HassanAliShahzad Let me explain, i need the the value should be display without click or refresh the page, so that i need AJAX,

– zus
Apr 9 at 5:23













ok now its second part after selection from where you will get result ? on the basis of two matched sections.

– Hassan Ali Shahzad
Apr 9 at 5:25






ok now its second part after selection from where you will get result ? on the basis of two matched sections.

– Hassan Ali Shahzad
Apr 9 at 5:25











1 Answer
1






active

oldest

votes


















1














For that you have two files basically, look the code your will get clear understanding for request flow also it will not change user selction:



your html file will be testing.html



<html>
<head>
<title> Upgrade Cost</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
</head>

<form method='POST' action='home.php'>

Name : <input type="text" name="name"/><br/><br/>
Email Id : <input type="text" name="email_id"/><br/><br/>
Contact Number : <input type="text" name="contact_number"/><br/><br/>
I have :
<select id="old">
<option value = "select_option">Select Option</option>
<option value = "one">One</option>
<option value = "two">Two</option>
<option value = "three">Three</option>
<option value = "four">Four</option>
<option value = "five">Five</option>
</select><br/><br/>
I want :
<select id="new">
<option value = "select_option">Select Option</option>
<option value = "one">One</option>
<option value = "two">Two</option>
<option value = "three">Three</option>
<option value = "four">Four</option>
<option value = "five">Five</option>
</select>
</form>
<!-- <button id="btn_check_value">Check for value</button> -->
<div id="result"></div>
<script>
$(document).ready(function()

$('#new').on('change',function()

var old_val = $("#old option:selected").val();
var new_val = $("#new option:selected").val();
$.ajax(
type: "POST",
url: "home.php",
dataType: "text",
data: old: old_val, new: new_val ,
success: function(data)
// Check the output of ajax call on firebug console
//console.log(data);
$('#result').html(data);

);

);
);

</script>
</html>


you ajax file will be:



<?php
if(isset($_POST['old']) && isset($_POST['new']))
$old = $_POST['old'];
$new = $_POST['new'];
if($old=='one'&&$new=='two')

// echo json_encode(array('Cost 10$'));
echo "Upgrade Code : 10$";


elseif($old=='one'&&$new=='three')

echo "Upgrade Code : 20$";


elseif($old=='one'&&$new=='four')

echo "Upgrade Code : 30$";



elseif($old=='one'&&$new=='five')

echo "Upgrade Code : 40$";

else
echo "Choose Valid Options";;


?>





share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269269%2fhow-to-fetch-results-from-server-using-jquery-ajax-on-the-basis-of-drop-down-co%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    For that you have two files basically, look the code your will get clear understanding for request flow also it will not change user selction:



    your html file will be testing.html



    <html>
    <head>
    <title> Upgrade Cost</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    </head>

    <form method='POST' action='home.php'>

    Name : <input type="text" name="name"/><br/><br/>
    Email Id : <input type="text" name="email_id"/><br/><br/>
    Contact Number : <input type="text" name="contact_number"/><br/><br/>
    I have :
    <select id="old">
    <option value = "select_option">Select Option</option>
    <option value = "one">One</option>
    <option value = "two">Two</option>
    <option value = "three">Three</option>
    <option value = "four">Four</option>
    <option value = "five">Five</option>
    </select><br/><br/>
    I want :
    <select id="new">
    <option value = "select_option">Select Option</option>
    <option value = "one">One</option>
    <option value = "two">Two</option>
    <option value = "three">Three</option>
    <option value = "four">Four</option>
    <option value = "five">Five</option>
    </select>
    </form>
    <!-- <button id="btn_check_value">Check for value</button> -->
    <div id="result"></div>
    <script>
    $(document).ready(function()

    $('#new').on('change',function()

    var old_val = $("#old option:selected").val();
    var new_val = $("#new option:selected").val();
    $.ajax(
    type: "POST",
    url: "home.php",
    dataType: "text",
    data: old: old_val, new: new_val ,
    success: function(data)
    // Check the output of ajax call on firebug console
    //console.log(data);
    $('#result').html(data);

    );

    );
    );

    </script>
    </html>


    you ajax file will be:



    <?php
    if(isset($_POST['old']) && isset($_POST['new']))
    $old = $_POST['old'];
    $new = $_POST['new'];
    if($old=='one'&&$new=='two')

    // echo json_encode(array('Cost 10$'));
    echo "Upgrade Code : 10$";


    elseif($old=='one'&&$new=='three')

    echo "Upgrade Code : 20$";


    elseif($old=='one'&&$new=='four')

    echo "Upgrade Code : 30$";



    elseif($old=='one'&&$new=='five')

    echo "Upgrade Code : 40$";

    else
    echo "Choose Valid Options";;


    ?>





    share|improve this answer



























      1














      For that you have two files basically, look the code your will get clear understanding for request flow also it will not change user selction:



      your html file will be testing.html



      <html>
      <head>
      <title> Upgrade Cost</title>
      <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
      </head>

      <form method='POST' action='home.php'>

      Name : <input type="text" name="name"/><br/><br/>
      Email Id : <input type="text" name="email_id"/><br/><br/>
      Contact Number : <input type="text" name="contact_number"/><br/><br/>
      I have :
      <select id="old">
      <option value = "select_option">Select Option</option>
      <option value = "one">One</option>
      <option value = "two">Two</option>
      <option value = "three">Three</option>
      <option value = "four">Four</option>
      <option value = "five">Five</option>
      </select><br/><br/>
      I want :
      <select id="new">
      <option value = "select_option">Select Option</option>
      <option value = "one">One</option>
      <option value = "two">Two</option>
      <option value = "three">Three</option>
      <option value = "four">Four</option>
      <option value = "five">Five</option>
      </select>
      </form>
      <!-- <button id="btn_check_value">Check for value</button> -->
      <div id="result"></div>
      <script>
      $(document).ready(function()

      $('#new').on('change',function()

      var old_val = $("#old option:selected").val();
      var new_val = $("#new option:selected").val();
      $.ajax(
      type: "POST",
      url: "home.php",
      dataType: "text",
      data: old: old_val, new: new_val ,
      success: function(data)
      // Check the output of ajax call on firebug console
      //console.log(data);
      $('#result').html(data);

      );

      );
      );

      </script>
      </html>


      you ajax file will be:



      <?php
      if(isset($_POST['old']) && isset($_POST['new']))
      $old = $_POST['old'];
      $new = $_POST['new'];
      if($old=='one'&&$new=='two')

      // echo json_encode(array('Cost 10$'));
      echo "Upgrade Code : 10$";


      elseif($old=='one'&&$new=='three')

      echo "Upgrade Code : 20$";


      elseif($old=='one'&&$new=='four')

      echo "Upgrade Code : 30$";



      elseif($old=='one'&&$new=='five')

      echo "Upgrade Code : 40$";

      else
      echo "Choose Valid Options";;


      ?>





      share|improve this answer

























        1












        1








        1







        For that you have two files basically, look the code your will get clear understanding for request flow also it will not change user selction:



        your html file will be testing.html



        <html>
        <head>
        <title> Upgrade Cost</title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
        </head>

        <form method='POST' action='home.php'>

        Name : <input type="text" name="name"/><br/><br/>
        Email Id : <input type="text" name="email_id"/><br/><br/>
        Contact Number : <input type="text" name="contact_number"/><br/><br/>
        I have :
        <select id="old">
        <option value = "select_option">Select Option</option>
        <option value = "one">One</option>
        <option value = "two">Two</option>
        <option value = "three">Three</option>
        <option value = "four">Four</option>
        <option value = "five">Five</option>
        </select><br/><br/>
        I want :
        <select id="new">
        <option value = "select_option">Select Option</option>
        <option value = "one">One</option>
        <option value = "two">Two</option>
        <option value = "three">Three</option>
        <option value = "four">Four</option>
        <option value = "five">Five</option>
        </select>
        </form>
        <!-- <button id="btn_check_value">Check for value</button> -->
        <div id="result"></div>
        <script>
        $(document).ready(function()

        $('#new').on('change',function()

        var old_val = $("#old option:selected").val();
        var new_val = $("#new option:selected").val();
        $.ajax(
        type: "POST",
        url: "home.php",
        dataType: "text",
        data: old: old_val, new: new_val ,
        success: function(data)
        // Check the output of ajax call on firebug console
        //console.log(data);
        $('#result').html(data);

        );

        );
        );

        </script>
        </html>


        you ajax file will be:



        <?php
        if(isset($_POST['old']) && isset($_POST['new']))
        $old = $_POST['old'];
        $new = $_POST['new'];
        if($old=='one'&&$new=='two')

        // echo json_encode(array('Cost 10$'));
        echo "Upgrade Code : 10$";


        elseif($old=='one'&&$new=='three')

        echo "Upgrade Code : 20$";


        elseif($old=='one'&&$new=='four')

        echo "Upgrade Code : 30$";



        elseif($old=='one'&&$new=='five')

        echo "Upgrade Code : 40$";

        else
        echo "Choose Valid Options";;


        ?>





        share|improve this answer













        For that you have two files basically, look the code your will get clear understanding for request flow also it will not change user selction:



        your html file will be testing.html



        <html>
        <head>
        <title> Upgrade Cost</title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
        </head>

        <form method='POST' action='home.php'>

        Name : <input type="text" name="name"/><br/><br/>
        Email Id : <input type="text" name="email_id"/><br/><br/>
        Contact Number : <input type="text" name="contact_number"/><br/><br/>
        I have :
        <select id="old">
        <option value = "select_option">Select Option</option>
        <option value = "one">One</option>
        <option value = "two">Two</option>
        <option value = "three">Three</option>
        <option value = "four">Four</option>
        <option value = "five">Five</option>
        </select><br/><br/>
        I want :
        <select id="new">
        <option value = "select_option">Select Option</option>
        <option value = "one">One</option>
        <option value = "two">Two</option>
        <option value = "three">Three</option>
        <option value = "four">Four</option>
        <option value = "five">Five</option>
        </select>
        </form>
        <!-- <button id="btn_check_value">Check for value</button> -->
        <div id="result"></div>
        <script>
        $(document).ready(function()

        $('#new').on('change',function()

        var old_val = $("#old option:selected").val();
        var new_val = $("#new option:selected").val();
        $.ajax(
        type: "POST",
        url: "home.php",
        dataType: "text",
        data: old: old_val, new: new_val ,
        success: function(data)
        // Check the output of ajax call on firebug console
        //console.log(data);
        $('#result').html(data);

        );

        );
        );

        </script>
        </html>


        you ajax file will be:



        <?php
        if(isset($_POST['old']) && isset($_POST['new']))
        $old = $_POST['old'];
        $new = $_POST['new'];
        if($old=='one'&&$new=='two')

        // echo json_encode(array('Cost 10$'));
        echo "Upgrade Code : 10$";


        elseif($old=='one'&&$new=='three')

        echo "Upgrade Code : 20$";


        elseif($old=='one'&&$new=='four')

        echo "Upgrade Code : 30$";



        elseif($old=='one'&&$new=='five')

        echo "Upgrade Code : 40$";

        else
        echo "Choose Valid Options";;


        ?>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 9 at 6:13









        Hassan Ali ShahzadHassan Ali Shahzad

        734317




        734317



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269269%2fhow-to-fetch-results-from-server-using-jquery-ajax-on-the-basis-of-drop-down-co%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

            Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?