I want to use variable in jquery selector to choose checked input and my code is below. what is wrong here?
function MyFunction(MyVariable){
var idAddress = $("input[name='id_address_" +MyVariable+ "']:checked").val();
alert(idAddress);
}
Syntactically, what you have is correct. It would get any inputs that have the name id_address_ + MyVariable that are checked, and then get the value of the first element, if multiple are returned. If the value of idAddress is null, then you are not getting anything returned from jQuery based on your selection criteria. For that we would need some more code to see the form elements, where MyVariable comes from, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With