Search the Community
Showing results for tags 'jquery javascript select onch'.
-
Hi, I have a radio button which, when clicked, is opening select. I would like to store the value of a radio and select into two separate cookies. This is my code I'm using, but I can't get second on change event to fire and get the value of select. I do get value of radio and store in cookie, but when trying to get value from select I get null. Can you, please help me and tell me what I'm doing wrong? Html code: <div class="row"> <div class="col-md-6"> <div class="radio clip-radio radio-primary"> <input type="radio" id="radio3" name="vertical" value="Pricelist" /> <label for="radio3"> Pricelist </label> </div> <div id="Pricelist" class="desc"> <div class="form-group"> <select class="cs-select cs-skin-elastic" name="pricelist" id="pricelist_select"> <option value="" disabled selected>Select pricelist</option> <option value="1">1</option> <option value="2">2</option> </select> </div> </div> jQuery //Displaying select box when type radio button is clicked $(document).ready(function() { $("input[name=vertical]").on( "change", function() { var test = $(this).val(); $(".desc").hide(); $("#"+test).show(); $("#pricelist_select").val(); $('#pricelist_select').trigger("change"); alert($("#pricelist_select").find(":selected").val()); $.cookie('pricelist_select', $("#pricelist_select").val()); } ); }); CSS .desc { display: none; }