javascript - jQuery show and hide dependent on value in C.I drop-down -


working in single view, have following c.i form_dropdown:

<?php $international_options = array(     '0' => lang('no'),     '1' => lang('yes') ); echo form_dropdown('international', $international_options, set_value('international', isset($stockists->international) ? $stockists->international : 0), 'class="span4 selectpicker international"'); ?> 

and have following file up-loader:

<label class="flagupload" for="filename">upload image flag</label> <input class='flagupload' type='file' name='filename' size='20' /> 

on same view (at bottom of view), have following script:

<script>     $(document).ready(function() {         $("#select.international").change(function() {             if ($('#select option:selected').text() == "yes") {                 $('.flagupload').show();             }             else if ($('#select option:selected').text() == "no") {                 $('.flagupload').hide();             }         });     }); </script> 

this attempts hide instances of flagupload if drop-down set no, or hides class if dropdown set 'yes'.

this not work, doesn't error either. can spot issue?

the html markup dropdown follows:

<select name="international" class="span4 selectpicker international"> <option value="0">no</option> <option value="1" selected="selected">yes</option> </select> 

use below short code.

<script>    $(document).ready(function() {        $("select.international").change(function() {            $('.flagupload').addclass('hide');             if ($(this).val() == "1") {                $('.flagupload').removeclass('hide');            }        });    }); </script> <style>    .hide    {         display:none ;    } </style> <select name="international" class="span4 selectpicker international">    <option value="0">no</option>    <option value="1" selected="selected">yes</option> </select> <label class="flagupload hide" for="filename">upload image flag</label> <input class="flagupload hide" type='file' name='filename' size='20' /> 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -