Home Forums Porto Admin Template Doubt with radio

This topic contains 1 reply, has 2 voices, and was last updated by  Support2 3 months, 1 week ago. This post has been viewed 136 times

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10018249

    ruben
    Participant

    Hello, i tried show two radios, and one of them load selected. I can with “cheched” attribute, but when change radio options, the attribute dont change, and when i tried get option selected, JQuery return always de default becouse de CSS only change label class.
    Can i solve this? Thanks!


    #10018259

    Support2
    Keymaster

    Hello,

    1) To show radio checked when the page load you are right using the attribute checked. Like this code below where the second radio loads checked:

    <div class="radio">
    	<label>
    		<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1">
    		Option one is this and that—be sure to include why it's great
    	</label>
    </div>
    <div class="radio">
    	<label>
    		<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2" checked>
    		Option two can be something else and selecting it will deselect option one
    	</label>
    </div>

    2) To return the value of radio checked with javascript/jQuery you can do some like this below:

    $(document).on('change', 'input[name="optionsRadios"]', function(){
    	setTimeout(function(){
    		alert($('input[name="optionsRadios"]:checked').val());
    	}, 1000);
    });

    Please try that and let me know if you need further assistance.

    Kind Regards,

    Rodrigo.


Viewing 2 posts - 1 through 2 (of 2 total)