How can I pass the value of the radio button below to the copy_select_val() function?
<input type="radio" name="selected_invoice" value="35" onclick="copy_select_val(); return false;">
How can I pass the value of the radio button below to the copy_select_val() function?
<input type="radio" name="selected_invoice" value="35" onclick="copy_select_val(); return false;">
function copy_select_val() {
alert($(this).val());
}
but I'm not user if this will also work on inline handlers like onclick. why dont you just setup a click eventlistener on this button?
Try this.value
to pass your radio's value to your function :
<input type="radio" name="selected_invoice" value="35"
onclick="copy_select_val(this.value); return false;">
Like this:
<input type="radio" name="selected_invoice" value="35"
onclick="copy_select_val(this.defaultValue); return false;">
JQuery is about being un-intrusive. Meaning, you don't need Javascript in your html elements directly. This said, you can do this:
$("input[name='selected_invoice']:checked").val();
If you are using JQuery you should keep the javascript out of the html.