« php: function with variable parameters
epp code from godaddy.com »

xajax and radio buttons

Categories: html, ajax

Tags: radio, xajax

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;
    }
}

Trackback address for this post

Trackback URL (right click and copy shortcut/link location)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)

Affliates

Spreadfirefox Affiliate Button