Topic: get the selected value from multiple radio buttons
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 ?
AdamJakubowski staff pro premium priority 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
bcatalin 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 ?
AdamJakubowski staff pro premium priority commented 5 years ago
try add the same html id to your element as you add in the java script code
soiware pro premium priority answered 4 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
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: 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