 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">Update Gallery</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">Front Setting</a></li>
              <li class="breadcrumb-item active">Update Gallery</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
         <div class="row">
            <div class="col-sm-12">
               <div class="card card-default">
                  <div class="card-header">
                     <h3 class="card-title">Update Gallery</h3>
                  </div>
                    <!-- /.card-header -->
                     <?php echo form_open_multipart(base_url().'admin/front_setting/update_gallery_image/'.$gallery->gallery_id);?>
                    <div class="card-body">
                      <div class="row">

                        <div class="col-md-8">
                           <div class="item form-group">
                              <label class="col-md-12 col-sm-12 col-xs-12">Select Category<span>*</span></label>
                              <div class="col-md-12 col-sm-12 col-xs-12">
                                 <select type="text" class="form-control"  name="gallery_category" placeholder="Enter Gallery Category Name" required>
                                    <option value="">Select A Category</option>
                                    <?php foreach ($all_category as $category):?>
                                       <option <?php if($category->gc_id == $gallery->gallery_category){echo 'selected';}?> value="<?php echo $category->gc_id; ?>"><?php echo $category->gc_name; ?></option>
                                    <?php endforeach; ?>
                                 </select>
                              </div>
                           </div>
                        </div>
                        <div class="col-md-4">
                           <div class="item form-group">
                              <label class="col-md-12 col-sm-12 col-xs-12">Select Mode<span>*</span></label>
                              <div class="col-md-12 col-sm-12 col-xs-12">
                                 <select onchange="mode(this.value)" type="text" class="form-control"  name="gallery_video_or_image" placeholder="Enter Gallery Category Name" required>
                                    <option value="">Select</option>
                                    <option <?php if( $gallery->gallery_video_or_image == 1){echo 'selected';}?> value="1">Image</option>
                                    <option <?php if($gallery->gallery_video_or_image == 2){echo 'selected';}?> value="2">Video</option>
                                 </select>
                              </div>
                           </div>
                        </div>
                        <div class="col-md-12" id="image_div">
                           <div class="item form-group">
                              <label class="col-md-12 col-sm-12 col-xs-12">Upload Image<span>*</span></label>
                              <div class="col-md-12 col-sm-12 col-xs-12">
                                 <input type="file" class="form-control"  name="gallery_image" placeholder="Enter Gallery Category Name" id="image_filed">
                              </div>
                           </div>
                           <div class="item form-group">
                              <label class="col-md-12 col-sm-12 col-xs-12">Preview Image</label>
                              <div class="col-md-12 col-sm-12 col-xs-12">
                                 <img src="<?php echo base_url(); ?><?php echo $gallery->gallery_image?>" alt="" width="70">
                              </div>
                           </div>
                        </div>
                        <div class="col-md-12" id="video_div">
                           <div class="item form-group">
                              <label class="col-md-12 col-sm-12 col-xs-12">Youtube Video URL<span>*</span></label>
                              <div class="col-md-12 col-sm-12 col-xs-12">
                                 <textarea  class="form-control"  name="gallery_video_iframe" placeholder="Enter Video URL" id="video_filed"><?php echo $gallery->gallery_video_iframe; ?></textarea>
                              </div>
                           </div>
                        </div>
                        <div class="col-md-12">
                          <div class="form-group">
                             <button name="form1" style="float: right" type="submit" class="btn btn-success">Update</button>
                          </div>
                        </div>
                        <?php echo form_close() ?>
                     </div>
                 </div>
               </div>   
            </div>
         </div>
      </div>
    </section>
  </div>
<style type="text/css">
#image_div, #video_div
{
   display: none;
}
</style>
<script type="text/javascript">
$( document ).ready(function() {
    mode(<?php echo $gallery->gallery_video_or_image; ?>);
});
function mode(e) 
{
   if(e == 1)
   {
      $('#image_div').show();
      $('#video_div').hide();
      $('#video_filed').attr('required', false);

   }
   else if(e == 2)
   {
      $('#image_div').hide();
      $('#video_div').show();
      $('#video_filed').attr('required', true);
   }
   else
   {
      $('#image_div').hide();
      $('#video_div').hide();
   }
}
</script>