Hidding and showing divs based on radial button choice
Hello,
Quick question please.
If I have 2 radial buttons
- <div class="form-group">
- <div class="radio">
- <label for="stock">
- <input type="radio" id="stock_disabled" name="stock" value="stock_disabled" checked><b>Disable</b> Stock Feature for this product
- <br>
- <input type="radio" id="stock_enabled" name="stock" value="stock_enabled"><b>Enable</b> Stock Feature for this product
- </label>
- </div>
- </div>
and an input field which I want to hide when the radial button
value="stock_disabled"
is chosen but show when
value="stock_enabled" is selected.
I have done this code at the moment but cannot get it working
this is the hidden field
- <div class="form-group" style="visibility: hidden;" id="show_stock" >
- <label for="product_stock">Current Stock</label>
- <input name="product_stock" type="text" placeholder="" class="form-control input-md">
- <span class="help-block">You can ""disable"" this feature if you wish by adding </span>
- </div>
And this is the jquery code:
- <script>
- $(document).ready(function(){
- $('#stock_disabled').on('change', function() {
- if ( this.value == 'stock_disabled')
- {
- $("#show_stock").show();
- }
- else
- {
- $("#show_stock").hide();
- }
- }).change();
- });
- </script>
Any idea what am I doing there please as the field is constantly hidden whatever I click.
Thank you!