People, please help. I do the repair cost calculator. I use jQuery. There are many fields, I will give an example of one of them, on which you need to understand. I do not understand why the variable radio111 does not get the value, but undefined.

<input type="radio" id="kbut" value="2150" name="radio111"> <label for="kbut" style="margin-right: 40px">Квартира</label> <input type="radio" id="taunbut" value="2200" name="radio111"> <label for="taunbut">Коттедж/Таунхаус</label> $('.formclass input').change(function(){ var radio111 = $('input[name="radio111"]:selected').val(); console.log(radio111); }); 

    1 answer 1

    You checkbox after all. :checked

     $('input').change(function(){ var radio111 = $('input[name="radio111"]:checked').val(); console.log(radio111); }); 
    • Sometimes it happens that it is even funny)) Thank you very much!) - PolonskiyP
    • @PolonskiyP if you have a pomg answer, I will be grateful if you mark it correct. - Oleksandr
    • so noted (up arrow, useful) - PolonskiyP
    • @PolonskiyP there under the down arrow there is a check mark, when clicking on it, you will mark the answer with one that helped you solve your problem. help This is useful if in the future a user will have a shedding like you, he can quickly understand for himself which of the answers fit you personally (and perhaps him). I looked at your profile for questions ... You have a lot of work to do) - Oleksandr