Get value of checked radiobutton using javascript

Eabz

New Member
I have created a radiobutton element. I would like to get the value that has been selected using element javascript, however I am finding it difficult to do so. I have used console.log to try and fish out the problem but the only value I seem to get is null or "Cannot read property 'get' of undefined".

I have tried using the following:
JavaScript:
    var pr = $('input[name=video___priority]:checked'); 
    var pr = form_75.getElements('video___priority').getValue();
    var pr = document.getElementById('video___priority').value();
    var pr = form_75.formElements.get('video___elementname').val();
    var pr = form_75.formElements.get('video___elementname').getValue();

I added two links where I found the first bit of code and the last bit of code that I wrote above.

stackoverflow.com/questions/9618504/get-radio-button-value-with-javascript
fabrikar.com/forums/index.php?threads/help-getting-radio-buton-values-in-element-js.29037/


I've also tried with various combinations of those components as well with no success.
I feel that this should be fairly easy but that I'm getting something wrong here, any help would be appreciated.
 
I haven't tried this but maybe something like:

var pr = jQuery('#video__priority input:radio')[0].value; or could just be .val

do a console.log of the jQuery and see what you get.
 
JavaScript:
jQuery('input[name="table___element_name[]"]:checked', '#table___element_name').val();
jQuery("#table___element_name input[type='radio']:checked").val();
jQuery("#list1___radio input:checked").val();
 
Last edited:
var pr = form_75.formElements.get('video___elementname').getValue();

That won't work, as form_75 doesn't exist as a global variable. Do ...

Code:
var form_75 = Fabrik.getBlock('form_75');
var pr = form_75.formElements.get('video___elementname').getValue();

... or just ...

Code:
var pr = Fabrik.getBlock('form_75').formElements.get('video___elementname').getValue();

The jQuery() methods will work, but it's typically easier to do it through the Fabrik object getValue() method, as then you don't need to worry about what input type it is, it'll work for anything - fields, radio buttons, checkboxes, textareas, whatever. The Fabrik element object handles extracting the value transparently.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top