by prettyscripts on 2008-10-24 10:28:53 • Leave a comment »
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