Wednesday, 1 March 2017

How to Fetch Data from Current address to Permanent address.


Fetch data from Current address to Permanent address. First of all you have to make a HTML form for Current address and Permanent address according to your field and call their id according to the javascript.  



<form action="" method="post">
                  <div class="row">
                            <div class="">
                              <div class="">
                              <div class=" form-group">
                                 <label class="">Current Address<span class="red">* </span></label>
                                 <textarea class="form-control" id="addr" name="Address" ></textarea>
                              </div>                                
                                <div class="">
                                   <label class="">State<span class="red">* </span></label>
                                  <select name="State" id="state" class="state form-control"  >
                                    <option selected="selected" value="">--- Select State ---</option>
                                    <option value='DELHI'>DELHI</option><option value='Karnataka'>Karnataka</option>
                                  </select>
                                </div>                                  
                                    <div class="">    
                                         <label class="">City<span class="red">* </span></label>
                                        <select name="city" id="city"  class="city form-control">
                                            <option selected="selected" value="">--- Select City ---</option>
                                            <option value='DELHI'>DELHI</option><option value='Bangalore'>Bangalore</option>
                                        </select>
                                    </div>
                                    <div class=""  id="othercity"  style="display:none;"> </div>                              
                                    <div class=" form-group">
                                         <label class="">Pin code<span class="red">* </span></label>
                                         <input type="number" name="Pincode" id="zipcode"   value="" class="form-control" />
                                    </div>
                                        <div class="">
                                            <input id="city" type="checkbox" name="city" value="" onclick="Functioncopy(this);"><label for="city"><strong class="s3">Is Your Permanent Address is same as Current Address</strong></label>
                                        </div>
                              </div>
                                <div class="">
                                    <div class="">
                                     
                                        <div class="">
                                             <label class="">Permanent Address<span class="red">* </span></label>
                                             <textarea class="form-control" id="addr1"  name="addr1" ></textarea>
                                        </div>
                                       
                                    </div>
                                   
                                        <div class="">  
                                            <label class="">State<span class="red">* </span></label>
                                            <select name="State1" id="state1" class="state1 form-control"  >
                                                <option selected="selected" value="">--- Select State ---</option>
                                                <option value='DELHI'>DELHI</option><option value='Karnataka'>Karnataka</option>
                                            </select>
                                        </div>

                                        <div class=" form-control">      
                                            <label class="">City<span class="red">* </span></label>
                                            <select name="same_city" id="same_city"  class="city1 form-control">
                                               <option selected="selected" value="">--- Select City ---</option>
                                               <option value='DELHI'>DELHI</option><option value='Bangalore'>Bangalore</option>
                                            </select>
                                        </div>
                                   
                              <div class=""  id="othercity1"  style="display:none;">       </div>

                            <div class="">    
                               <label class="">Pincode<span class="red">* </span></label>
                              <input type="number" name="pin1" id="pin1"  value="" class="form-control" />
                              </div>
                           </div>
                        </div>
                     </div>
                 
                <div class="col-md-12">
                      <div class="col-md-6">
                          <input type="submit"  class="btn btn-info "  name="submit" value="Submit" />
                      </div>
                 </div>

            </form>

<script type="text/javascript">
      function Functioncopy(checkbox) {
        if (checkbox.checked) {
            document.getElementById("addr1").value = document.getElementById("addr").value;
            document.getElementById("state1").value = document.getElementById("state").value;
             var c = document.getElementById("city").value;  
            document.getElementById("pin1").value = document.getElementById("zipcode").value;
            //alert(''+c);
            if(c == 'other')
            {    
                document.getElementById("same_city").style.display = "block";
                document.getElementById("same_city").value = c;
                document.getElementById("othercity1").style.display = "block";
                var html = othercity1();
                $("#othercity1").html(html);              
                document.getElementById("othercity4").value = document.getElementById("othercity3").value;
            }
            else{
                document.getElementById("same_city").style.display = "block";  
                document.getElementById("same_city").value = c;                
                var html = '';
                $("#othercity1").html(html);  
                document.getElementById("othercity1").style.display = "none";
            }

            document.getElementById("city1").style.display = "none" ;
        }
        else {
            document.getElementById("addr1").value = "";
            document.getElementById("state1").value = "";
            document.getElementById("city1").value = "";
            document.getElementById("pin1").value = "";
             document.getElementById("same_city").style.display = "none";
            document.getElementById("city1").style.display = "block" ;
        }
    }
 
</script>

0 comments:

Post a Comment