xajax and radio buttons

to display a group of choices to select-only-one as radio buttons, the name and id parameters must be the same for all <input> tags:

<input type="radio" name="option" id="option" value="1" onclick="xajax_click(this.value);" checked />option 1
<input type="radio" name="option" id="option" value="2" onclick="xajax_click(this.value);" />option 2
<input type="radio" name="option" id="option" value="3" onclick="xajax_click(this.value);"/>option 3

to pass the value of radio button to xajax function, use this.value. not this.checked, as the value is always true when it’s clicked.

function click($value) {
    $x = new xajaxResponse();
    switch ($value) {
    case 1:
        //do something
        break;
    case 2:
        //do something
        break;
    case 3:
        //do something
        break;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *