xajax and radio buttons

by prettyscripts on 2008-10-24 10:28:53 • Leave a comment »

htmlxajax

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>.

the html code:

Code:

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

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.

the xajax function:

PHP:

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

Tags: form, radio button, xajax

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)