重新加载后,表单值消失

时间:2016-03-19 05:50:20

标签: javascript php jquery codeigniter

当我选择颜色字段时,子类别字段中选择的值消失 这是我的观点页面......

 <div class="form-group col-md-12">
          <label class="form-group col-md-3" for="exampleInputEmail1">Parent Category</label> 

              <div class="form-group col-md-6">
              <select name="parentname" id="parentname" class="form-control">
                <option value="">select one</option>
                <?php foreach ($parent as $row) { ?>
                  <option value="<?php echo $row->id; ?>"><?php echo $row->category_name; ?></option>
                <?php } ?>
              </select>
            </div>
      </div>
      <div class="form-group col-md-12">
          <label class="form-group col-md-3" for="exampleInputEmail1">Sub Category</label> 

              <div class="form-group col-md-6">
              <select name="subname" id="subname" class="form-control">
                <option value="">select one</option>
                  <?php foreach ($sub_cat as $row){?>
                <option value="<?php echo $row->id;?>"><?php echo $row->category_name;?></option>
            <?php }?> 
              </select>
            </div>
      </div>
 <div class="form-group col-md-12">
          <label class="form-group col-md-3" for="exampleInputEmail1">Color</label> 

              <div class="form-group col-md-6">
              <input readonly id="mycolor" class="colorPicker evo-cp0 form-control" data-toggle="tooltip" data-placement="top" title="Pick Product color" />
            </div>
      </div>

      <div class="form-group col-md-12">
        <label for="exampleInputPassword1">Selected Colors</label>
        <div class="clearfix"></div>

         <div id="selected-color">
           <?php if($this->session->userdata('colors')){
                foreach ($this->session->userdata('colors') as $color)
                {?>
            <div class="col-md-2 selected-color">
                <div class="color-box" style="background-color:<?php echo $color; ?>"></div>
                <div class="selected-color-btn" color='<?php echo $color; ?>' data-toggle="modal" data-target="#confirm-color" >
                <span class="fa fa-close" data-toggle="tooltip" data-placement="top" title="Remove color"  ></span></div>
            </div> 
            <?php }}?>
         </div>
        </div>

这是我的js ......

<script type="text/javascript">
$(document).ready(function() {
  $('#mycolor').css('background-color', $('#mycolor').val());

  $("#mycolor").colorpicker({});

  $("#mycolor").on("change.color", function(event, color){

       var url='<?php echo base_url() ?>admin_control/ajax_addProduct_color';
       var product_id=$("#product_id").val();

       $.post(url, {color:color,product:product_id}, function(result)
          {
            $('#selected-color').html(result);
             location.reload();

          });
  });
<script>

我有sisyphus函数,在选择颜色字段后选择值,但是当我选择颜色字段时,子类别字段的值消失

0 个答案:

没有答案