Advertisement
joris

Form Yii

Oct 10th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.72 KB | None | 0 0
  1. <script>
  2. $(document).ready(function(e) {
  3.     $("input[type=checkbox]").click(function(){
  4.         if ($(this).attr("checked") == "checked"){
  5.             $("#DistributionPlan_ship_pic_name").attr("readonly","readonly");
  6.             $("#DistributionPlan_ship_pic_phone").attr("readonly","readonly");
  7.             $("#DistributionPlan_ship_pic_mobile").attr("readonly","readonly");
  8.             $("#DistributionPlan_ship_title").attr("readonly","readonly");
  9.             $("#DistributionPlan_ship_address").attr("readonly","readonly");
  10.             $("#DistributionPlan_ship_province").attr("readonly","readonly");
  11.             $("#DistributionPlan_ship_city").attr("readonly","readonly");
  12.             $("#DistributionPlan_zip_code").attr("readonly","readonly");
  13.             checkData();
  14.         }else{
  15.             $("#DistributionPlan_ship_pic_name").removeAttr("readonly");
  16.             $("#DistributionPlan_ship_pic_phone").removeAttr("readonly");
  17.             $("#DistributionPlan_ship_pic_mobile").removeAttr("readonly");
  18.             $("#DistributionPlan_ship_title").removeAttr("readonly");
  19.             $("#DistributionPlan_ship_address").removeAttr("readonly");
  20.             $("#DistributionPlan_ship_province").removeAttr("readonly");
  21.             $("#DistributionPlan_ship_city").removeAttr("readonly");
  22.             $("#DistributionPlan_zip_code").removeAttr("readonly");
  23.             //==========================================================
  24.             $("#DistributionPlan_ship_pic_name").val('');
  25.             $("#DistributionPlan_ship_pic_phone").val('');
  26.             $("#DistributionPlan_ship_pic_mobile").val('');
  27.             $("#DistributionPlan_ship_title").val('');
  28.             $("#DistributionPlan_ship_address").val('');
  29.             $("#DistributionPlan_ship_province").val('');
  30.             $("#DistributionPlan_ship_city").val('');
  31.             $("#DistributionPlan_zip_code").val('');
  32.             $("#DistributionPlan_ship_pic_name").focus();
  33.         }
  34.     });
  35. });
  36.  
  37. function checkData(){
  38.     $.ajax({
  39.         type: 'GET',
  40.         url: '<?php echo Yii::app()->createAbsoluteUrl("distributionplan/matchdata"); ?>',
  41.         dataType: 'json',
  42.         cache: false,
  43.         success: function (result) {
  44.             $("#DistributionPlan_ship_pic_name").val(result[0].pic_name);
  45.             $("#DistributionPlan_ship_pic_phone").val(result[0].pic_phone_number);
  46.             $("#DistributionPlan_ship_pic_mobile").val(result[0].pic_mobile_number);
  47.             $("#DistributionPlan_ship_title").val(result[0].region_office_title);
  48.             $("#DistributionPlan_ship_address").val(result[0].region_address);
  49.             $("#DistributionPlan_ship_province").val(result[0].province);
  50.             $("#DistributionPlan_ship_city").val(result[0].city);
  51.             $("#DistributionPlan_zip_code").val(result[0].zip_code);
  52.             $("html, body").animate({ scrollTop: $(document).height() }, "slow");
  53.         },
  54.         error: function(jqXHR, exception){
  55.             alert('Error : Match region data');
  56.         }
  57.     });
  58. }
  59. </script>
  60.  
  61. <input type="checkbox" id="copyData" class="css-checkbox med"/>
  62. <label for="copyData" name="copyData_lbl" class="css-label med elegant">Copy from current data</label>
  63.  
  64. <br /><br />
  65.  
  66. <div class="formSep">
  67.         <label>
  68.         <?php echo $form->labelEx($model,'ship_pic_name'); ?>
  69.         </label>
  70.        
  71.         <?php echo $form->textField($model,'ship_pic_name',array('size'=>50,'maxlength'=>50,'autocomplete'=>'off')); ?>
  72.         <span class="help-inline">
  73.         <?php echo $form->error($model,'ship_pic_name'); ?>
  74.         </span>
  75.    
  76.    
  77.    
  78.         <label>
  79.         <?php echo $form->labelEx($model,'ship_pic_phone'); ?>
  80.         </label>
  81.        
  82.         <?php echo $form->textField($model,'ship_pic_phone',array('size'=>50,'maxlength'=>50,'autocomplete'=>'off')); ?>
  83.         <span class="help-inline">
  84.         <?php echo $form->error($model,'ship_pic_phone'); ?>
  85.         </span>
  86.    
  87.    
  88.    
  89.         <label>
  90.         <?php echo $form->labelEx($model,'ship_pic_mobile'); ?>
  91.         </label>
  92.        
  93.         <?php echo $form->textField($model,'ship_pic_mobile',array('size'=>50,'maxlength'=>50,'autocomplete'=>'off')); ?>
  94.         <span class="help-inline">
  95.         <?php echo $form->error($model,'ship_pic_mobile'); ?>
  96.         </span>
  97.    
  98.    
  99.    
  100.         <label>
  101.         <?php echo $form->labelEx($model,'ship_title'); ?>
  102.         </label>
  103.        
  104.         <?php echo $form->textField($model,'ship_title',array('size'=>60,'maxlength'=>100,'autocomplete'=>'off')); ?>
  105.         <span class="help-inline">
  106.         <?php echo $form->error($model,'ship_title'); ?>
  107.         </span>
  108.    
  109.    
  110.    
  111.         <label>
  112.         <?php echo $form->labelEx($model,'ship_address'); ?>
  113.         </label>
  114.        
  115.         <?php echo $form->textArea($model,'ship_address',array('rows'=>6, 'cols'=>50, 'class'=>'span7')); ?>
  116.         <span class="help-inline">
  117.         <?php echo $form->error($model,'ship_address'); ?>
  118.         </span>
  119.    
  120.    
  121.    
  122.         <label>
  123.         <?php echo $form->labelEx($model,'ship_province'); ?>
  124.         </label>
  125.        
  126.         <?php echo $form->textField($model,'ship_province',array('size'=>50,'maxlength'=>50,'autocomplete'=>'off')); ?>
  127.         <span class="help-inline">
  128.         <?php echo $form->error($model,'ship_province'); ?>
  129.         </span>
  130.    
  131.    
  132.    
  133.         <label>
  134.         <?php echo $form->labelEx($model,'ship_city'); ?>
  135.         </label>
  136.        
  137.         <?php echo $form->textField($model,'ship_city',array('size'=>50,'maxlength'=>50,'autocomplete'=>'off')); ?>
  138.         <span class="help-inline">
  139.         <?php echo $form->error($model,'ship_city'); ?>
  140.         </span>
  141.    
  142.    
  143.    
  144.         <label>
  145.         <?php echo $form->labelEx($model,'zip_code'); ?>
  146.         </label>
  147.        
  148.         <?php echo $form->textField($model,'zip_code',array('size'=>60,'maxlength'=>255,'autocomplete'=>'off')); ?>
  149.         <span class="help-inline">
  150.         <?php echo $form->error($model,'zip_code'); ?>
  151.         </span>
  152.    
  153.  
  154. </div>
  155.  
  156. <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn btn-success')); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement