Skip to main content

Using single jQuery Ajax function/Call to load child dropdown based on Parent dropdown selction instead of multiple functions

Using single jQuery Ajax function/Call to load child drop down based on Parent drop down selection instead of multiple functions.

<script type="text/javascript">
$(document).ready( function() {
   
    // All in On RNS Ajax Call
    $('.rnscall').on('change', function(){       
        var val = $(this).find('option:selected').val();
        var rnsid=this.id;

        if(rnsid=="proj_city_id") {
            var dataString = 'city_id='+val+'&drop=loc'; var rnsresult="#proj_loc_id";
        } else if(rnsid=="proj_type") {
            var dataString = 'type_id='+val+'&drop=subtype'; var rnsresult="#proj_subtype";
        }

        $.ajax({
            type: "POST", url: "ajax.php", data: dataString, cache: false,
            success: function(data){
                $(rnsresult).html(data);
            }
        });
    });
});
</script>


<div class="row"> <span class="label">Type <span class="red">*</span></span> <span class="item">
  <select name="proj_type" id="proj_type" class="rnscall" style="width: 310px" required>
    <?php call_user_func_array('rns_drop_foreach',array($proptype_arr, @$row['proj_type'],"Type")); ?>
  </select>
  </span>
  <div class="clear"></div>
</div>
<div class="row"> <span class="label">Sub Type <span class="red">*</span></span> <span class="item">
  <select name="proj_subtype" id="proj_subtype" style="width: 310px" required>
    <option value="">Select Sub Type</option>
    <?php if(!empty($_GET['id'])){ call_user_func_array('dropdown',array('si_property_type', 'pt_id,pt_name', 'pt_status=1 order by pt_name', @$row['proj_subtype'])); } ?>
  </select>
  </span>
  <div class="clear"></div>
</div>
<div class="row"> <span class="label">City <span class="red">*</span></span> <span class="item">
  <select name="proj_city_id" id="proj_city_id" class="rnscall" placeholder="City Name" style="width: 310px" required>
    <option value="">Select City Name</option>
    <?php  dropdown('si_cities', 'city_id,city_name', 'city_status=1 order by city_name', @$row['proj_city_id']);  ?>
  </select>
  </span>
  <div class="clear"></div>
</div>
<div class="row"> <span class="label">Location <span class="red">*</span></span> <span class="item">
  <select name="proj_loc_id" id="proj_loc_id" placeholder="Designation" style="width: 310px" required>
    <option value="">Select Location</option>
    <?php if(!empty($_GET['id'])){ dropdown('si_locations', 'loc_id,loc_name', 'loc_status=1 order by loc_name', @$row['proj_loc_id']); } ?>
  </select>
  </span>
  <div class="clear"></div>
</div>

Comments

Popular posts from this blog

How to create a Barcode Using PHP Barcode 128 Generator

A barcode is an optical, machine-readable, representation of data, the data usually describes something about the object that carries the barcode.We will use PHP to generate Barcode in this tutorial. In this script, we are using coding which will generate barcodes in barcode format Code 128 . First, we will create index.php which will ask for the user input for which Barcode has to be created PHP Barcode Generator <fieldset><legend>Detail Informations</legend><form action="createbarcode.php" method="post"><b>Enter Your Code </b><input name="barcode" type="text" /><input type="submit" value="Create Barcode" /></form></fieldset> Now we will create createbarcode.php which will call function from Barcode code128 class for creating barcode <? php include('barcode128.php'); // include php barcode 128 class // design our barcode display echo...

How to Change Currency Symbol Position - Magento 2

The default Magento 2 shows the currency symbol on the left side. However it does not have a feature to change the currency location from left to right.    Programmatic solution to change currency symbol position in Magento 2.   Solution to Change Currency Symbol Position in Magento 2 Create events.xml file at app/code/vendor/Exenstion/etc/frontend   <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">     <event name="currency_display_options_forming">         <observer name="change_currency_position" instance="vendor\Exenstion\Observer\ChangeCurrencyPosition"/>     </event> </config>  Create ChangeCurrencyPosition.php file at app/code/vendor/Exenstion/Observer      <?php namespace vendor\Exensti...

Symbols Used in Excel Formula | The purpose of Symbols in Excel Formula

Following symbols are used in Excel Formula. They will perform different actions in Excel Formulas and Functions. Each of these special characters have used for different purpose in Excel. Symbol Name Description = Equal to Every Excel Formula begins with Equal to symbol (=). Example: = B1+B6 () Parentheses All Arguments of the Excel Functions specified between the Parentheses. Example: =COUNTIF ( B1:B5,5 ) () Parentheses Expressions specified in the Parentheses will be evaluated first. Parentheses changes the order of the evaluation in Excel Formula. Example:   =25+ ( 35*2 ) +5 * Asterisk Wild card operator to to denote all values in a List. Example:   =COUNTIF(B1:B5,” * “) , Comma List of the Arguments of a Function Separated by Comma in Excel Formula. Example:   =COUNTIF(B1:B5 , “>” &C1) & Ampersand Concatenate Operator to connect two strings into one in Excel Formula. Example:   =”Total: “ & SUM(C2:C25) $ Dollar Makes Cell Reference as Absolute in ...