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
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
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- 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