aveeva7 0 Newbie Poster

I have predefined value like shipping_weight = 10$, my form consisting two dropdown list, if the dropdown selected based on the selection how to return my ajax value,

Index.php :

    <tr>
        <th>I have : </th>
        <td>
            <select id="old" name="i_have">
                <option value = "select_option">Select Option</option>
                <option value = "three_compact">3 Compact</option>
                <option value = "three_regular">3 Regular</option>
                <option value = "three_triple">3 Triple</option>
                <option value = "five_compact">5 Compact</option>
                <option value = "five_regular">5 Regular</option>
                <option value = "five_triple">5 Triple</option>
                <option value = "seven_compact">7 Compact</option>
                <option value = "seven_regular">7 Regular</option>
                <option value = "seven_triple">7 Triple</option>
                <option value = "nine_compact">9 Compact</option>
                <option value = "nine_regular">9 Regular</option>
                <option value = "nine_triple">9 Triple</option>
            </select>
        </td>
    </tr>

    <tr>
        <th>I want : </th>
        <td>
            <select id="new" name="i_want">
                <option value = "select_option">Select Option</option>
                <option value = "three_compact">3 Compact</option>
                <option value = "three_regular">3 Regular</option>
                <option value = "three_triple">3 Triple</option>
                <option value = "five_compact">5 Compact</option>
                <option value = "five_regular">5 Regular</option>
                <option value = "five_triple">5 Triple</option>
                <option value = "seven_compact">7 Compact</option>
                <option value = "seven_regular">7 Regular</option>
                <option value = "seven_triple">7 Triple</option>
                <option value = "nine_compact">9 Compact</option>
                <option value = "nine_regular">9 Regular</option>
                <option value = "nine_triple">9 Triple</option>
            </select>
        </td>
    </tr>

    <tr>
        <th>Shipping Weight : </th> 
        <td id="results"></td>
        <input type="hidden" name="shipping_weight" id="shipping_weight"/>
    </tr> 
    <tr>    

    <script>
        $(document).ready(function(){
        $('#new').on('change',function(){

        var ship_val = $("#est_shi_val").val();
        $.ajax({
        type: "POST",
        url: "ajax_ship_data.php",
        dataType: "text",
        data: {est_shi_val: ship_val },
        success: function(data)
        {
            // Check the output of ajax call on firebug console
            // console.log(data);
            $('#results').html(data);
            $('#shipping_weight').val(data);
        }
});

});
});

</script>

My value is,

ajax_ship_data.php

if(isset($_POST['old']) && isset($_POST['new'])){
$old = $_POST['old'];
$new = $_POST['new'];

// three step kolupadi combination 

//part 1 

if($old=='three_compact'&&$new=='five_compact'){  // 6250111

/** echo json_encode(array('Cost 10$')); */
echo "10";
}

How get my shipping weight if two drop down seleted.
FYI -> https://snag.gy/pNaEMv.jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.