How to Fetch results from server using JQuery AJAX? on the basis of Drop-down ConditionHow to structure Ajax...

Landing in very high winds

Should the British be getting ready for a no-deal Brexit?

New order #4: World

How to move the player while also allowing forces to affect it

(Soft question) does light intensity oscillate really fast since it is a wave?

Is there a familial term for apples and pears?

Does it makes sense to buy a new cycle to learn riding?

Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?

What causes the sudden spool-up sound from an F-16 when enabling afterburner?

Is Social Media Science Fiction?

Symmetry in quantum mechanics

Are cabin dividers used to "hide" the flex of the airplane?

What to wear for invited talk in Canada

Why do we use polarized capacitors?

Is there a name of the flying bionic bird?

Was there ever an axiom rendered a theorem?

What does 'script /dev/null' do?

Ideas for 3rd eye abilities

How could a lack of term limits lead to a "dictatorship?"

extract characters between two commas?

Prime joint compound before latex paint?

Is a vector space a subspace of itself?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Does a dangling wire really electrocute me if I'm standing in water?



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


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
    1 hour ago











  • @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
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago











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

    – zus
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago




















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
    1 hour ago











  • @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
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago











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

    – zus
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago
















0












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
















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 25 mins ago









Hassan Ali Shahzad

709317




709317










asked 1 hour ago









zuszus

87119




87119













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

    – divya sekar
    1 hour ago











  • @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
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago











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

    – zus
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago





















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

    – divya sekar
    1 hour ago











  • @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
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago











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

    – zus
    1 hour ago











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

    – Hassan Ali Shahzad
    1 hour ago



















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

– divya sekar
1 hour ago





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

– divya sekar
1 hour ago













@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
1 hour ago





@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
1 hour ago













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

– Hassan Ali Shahzad
1 hour ago





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

– Hassan Ali Shahzad
1 hour ago













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

– zus
1 hour ago





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

– zus
1 hour ago













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

– Hassan Ali Shahzad
1 hour ago







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

– Hassan Ali Shahzad
1 hour ago












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 38 mins ago









        Hassan Ali ShahzadHassan Ali Shahzad

        709317




        709317






























            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

            “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

            How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

            夢乃愛華...