Topic: get the selected value from multiple radio buttons

bcatalin free asked 5 years ago


On this snippet https://mdbootstrap.com/snippets/jquery/bcatalin/857933 How can I get the text "Option x" depending on which radio button was clicked ?


soiware priority answered 3 years ago


Assign the "value" attribute in the "input" tag:

<input type="radio" class="form-check-input" id="materialGroupExample1" name="groupOfMaterialRadios" value="1">

Assign it to every radio input element


Marcin Luczak staff commented 3 years ago

Thank you @soiware for helping our community :)


bcatalin free answered 5 years ago


Yes. see updated snippet. It shows and empty string value.

I've tried also console.log($("input[name='groupOfMaterialRadios']:checked").val()) but just return "on" string

Do you have any ideas ?


Adam Jakubowski staff commented 5 years ago

try add the same html id to your element as you add in the java script code


Adam Jakubowski staff answered 5 years ago


Hi,

did you try to use this jQuery .text() method ?labelText = $("#myLabel").text()) try to add this to your code

Best,

Adam



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.8.4
  • Device: PC
  • Browser: chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: Yes