1

I have form which is get details form customer and also calculate amount of the product, how can i pass total value which is get form and pass to CCAvenue payment page.

My form :

<html>
    <head>
        <title> Upgrade Cost</title>
        <script src="css/googleapis/jquery.min.js"></script>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <script src="css/jquery.min.js"></script>
        <script src="css/bootstrap.min.js"></script>
     </head>
    <body>
        <!-- Ajax data -->
        <div class="container"> 

            <div class="jumbotron jumbotron-fluid">
                <div class="container">
                    <h1>KoluPadi Upgrade Form</h1>      
                </div>
            </div>

                <form action='ccavRequestHandler.php' method='POST' > 
                <div class="form-group">
                    <label class="control-label col-sm-2" for="first_name">First Name :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter First Name" name="first_name">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-2" for="last_name">Last Name :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter Last Name" name="last_name">
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-sm-2" for="address">Address :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter Address" name="address">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-2" for="city">City :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter City" name="city">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-2" for="state_province">State/Province :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter State/Province" name="state_province">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-2" for="zip_postal_code">Zip/Postal Code :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter Zip/Postal Code" id="zip_postal_code" name="zip_postal_code">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-2" for="country">Country :</label>
                    <div class="col-sm-10">  
                         <input type="text" class="form-control" placeholder="Enter Country" id="country" name="country">
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-sm-2" for="email_id">Email Id :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter Email Id" name="email_id">
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-sm-2" for="mobile_number">Mobile Number :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control" placeholder="Enter Mobile Number" name="mobile_number">
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-sm-2" for="i_have">I have :</label>
                    <div class="col-sm-10">  
                        <select id="old" class="form-control" placeholder="Select I have" 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>
                    </div>
                </div>




                <div class="form-group">
                    <label class="control-label col-sm-2" for="i_want">I want :</label>
                    <div class="col-sm-10">  
                        <select id="new" class="form-control" placeholder="Select I want" 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>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-2" for="price">Price (Rs) :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control"  id="price" name="price"  readonly>
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-sm-2" for="shipping_weight">Shipping Weight :</label>
                    <div class="col-sm-10">  
                        <input type="text" class="form-control"  id="shipping_weight" name="shipping_weight" readonly>
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-sm-2" for="shipping_cost">Shipping Cost (Rs) :</label>
                    <div class="col-sm-10">  
                        <select id="findata" class="form-control" id="shipping_cost" name="shipping_cost"  ></select>
                    </div>
                </div>



                <div class="form-group">
                    <label class="control-label col-sm-2" for="grand_total">Grand Total: :</label> 
                    <div class="col-sm-10">  
                        <input type="text" class="form-control"  id="grand_total" name="grand_total" readonly>
                    </div>
                </div>         

                <div class="form-group">        
                     <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-default" id="pass">Pay</button>
                    </div>
                </div>

            </form>
        </div>    
        </body>
    <!-- <button id="btn_check_value">Check for value</button>  -->

    <!-- Ajax Script -->

    <script>

        // Price
        $(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: "ajax_price.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);
                        $('#price').val(data);

                    }
                });

            });
        });    

        // Weight
        $(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: "ajax_ship_weight.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);
                        $('#show').html(data);
                        $('#shipping_weight').val(data);

                    }
                });
            });
        });

        //Shipping_cost
        $(document).ready(function(){
            $('#new').on('change',function(){

                var zip = $("#zip_postal_code").val();
                var country = $("#country").val();

                $.ajax({
                type: "POST",
                // url: "ajax_ship_cost_data.php",
                url: "sp_cost.php",
                dataType: "text",
                data: { zip_postal_code: zip, country: country},
                success: function(data)
                     {
                        // Check the output of ajax call on firebug console
                        //console.log(data);
                        $('#findata').html(data);
                        $('#shipping_cost').val(data);

                    }
                });
            });
        });

        // Grand Total
        $(document).ready(function(){
            $('#findata').on('change',function(){

                var price = $("#price").val();
                var shipping_cost = $("#findata").val();

                $.ajax({
                type: "POST",
                url: "gt.php",
                dataType: "text",
                data: { price: price, shipping_cost: shipping_cost },
                success: function(data)
                    {
                        // Check the output of ajax call on firebug console
                        // console.log(data);
                        $('#total').html(data);
                        $('#grand_total').val(data);

                    }
                });
            });
        });

        // ###### passing data to db  #######
        $(document).ready(function(){
            $('#pass').on('click',function(){

                var first_name      = $("#first_name").val();
                var last_name       = $("#last_name").val();
                var address         = $("#address").val();
                var city            = $("#city").val();
                var state_province  = $("#state_province").val();
                var zip_postal_code = $("#zip_postal_code").val();
                var country         = $("#country").val();
                var email_id        = $("#email_id").val();
                var mobile_number   = $("#mobile_number").val();
                var i_have          = $("#i_have").val();
                var i_want          = $("#i_want").val();
                var price           = $("#price").val();
                var shipping_weight = $("#shipping_weight").val();
                var shipping_cost   = $("#shipping_cost").val();
                var grand_total     = $("#grand_total").val();


                $.ajax({
                type: "POST",
                url: "ajax_data.php",
                dataType: "text",
                data: 
                    {
                        first_name      :  first_name,
                        last_name       :  last_name,
                        address         :  address,
                        city            :  city,
                        state_province  :  state_province,
                        zip_postal_code :  zip_postal_code,
                        country         :  country,
                        email_id        :  email_id,
                        mobile_number   :  mobile_number,
                        i_have          :  i_have,
                        i_want          :  i_want,
                        price           :  price,
                        shipping_weight :  shipping_weight,
                        shipping_cost   :  shipping_cost,
                        grand_total     :  grand_total
                    }
                    // ,
                    // success: function(data)
                    // {
                        // Check the output of ajax call on firebug console
                        // console.log(data);
                        // $('#pass').html(data);
                        // $('#price').val(data);

                    // }
                });

            });
        });

    </script> 
</html>

Does anyone know how to solve it? Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.