...

View Full Version : Prototype.js and radio buttons



MacCult
04-19-2006, 08:25 PM
Hi,

I am doing a form validation using Prototype.js. My problem is validating radio button. I am using Form.Element.Serializers.inputSelector to validate the radio button. I understand that it will return an array. I am wondering how do I go about checking which radio button is checked. Please reply soon.

Thanks.

KC-Luck
04-19-2006, 09:53 PM
you should just use $F(buttonID)
it will return the selected @value, if any

SecretPete
07-13-2007, 12:46 AM
Instead of:
var typeValue = $F('type');

Use this:
var typeValue = Form.getInputs('myform','radio','type').find(function(radio) { return radio.checked; }).value;

From Rex Chung:
http://www.rexchung.com/2007/02/22/getting-radio-buttons-value-with-prototypejs/

al.caughey
04-30-2009, 06:03 AM
I use the function provided at http://xavisys.com/2007/03/using-prototype-javascript-to-get-the-value-of-a-radio-group/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum