AJAX Page - Knowledge Base

« Back to Knowledge Base list

Getting the value of checked radio button


How to get the value of checked radio button in client-side for posting to server-side?


This client-side code block can be used:

<input name="FindBy" type="radio" value="QN" checked="checked" />QueryName

<input name="FindBy" type="radio" value="QID" />QueryID

<input name="FindBy" type="radio" value="AID" />AdvertiserID

<input name="FindBy" type="radio" value="UN" />UserName

<script type="text/javascript">
function GetCheckedValue(){
            var chkElement = '';
            var radioButtons = document.getElementsByName('
            for(var i = 0; i < radioButtons.length; i++)

                    var elem = radioButtons[i];
                        chkElement = elem.value;
            return chkElement;
        function ServerLookup()
            ob_post.AddParam("FindBy", GetCheckedValue());
            ob_post.post(null, "loadData", "EndLookup");


The client-side variable chkElement will hold the value of the checked element, which can be passed server-side.