Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 单选按钮组,更改事件?_Php_Events_Cakephp_Radio Button - Fatal编程技术网

Php 单选按钮组,更改事件?

Php 单选按钮组,更改事件?,php,events,cakephp,radio-button,Php,Events,Cakephp,Radio Button,我有一组由cakephp生成的单选按钮 <input type="radio" name="data[hexInput]" id="HexInput1" value="h1"> <input type="radio" name="data[hexInput]" id="HexInput2" value="h2"> <input type="radio" name="data[hexInput]" id="HexInput3" value="h3"> 只需为每

我有一组由cakephp生成的单选按钮

<input type="radio" name="data[hexInput]" id="HexInput1" value="h1">
<input type="radio" name="data[hexInput]" id="HexInput2" value="h2">
<input type="radio" name="data[hexInput]" id="HexInput3" value="h3">

只需为每个单选按钮创建一个onclick。你可以这样做:

function update(val) {
    alert("Radio button changed to " + val);
}
<input onclick="update(this.value);" type="radio" name="data[hexInput]" id="HexInput1" value="h1">
<input onclick="update(this.value);" type="radio" name="data[hexInput]" id="HexInput2" value="h2">
<input onclick="update(this.value);" type="radio" name="data[hexInput]" id="HexInput3" value="h3">
然后将其连接到每个输入,如下所示:

function update(val) {
    alert("Radio button changed to " + val);
}
<input onclick="update(this.value);" type="radio" name="data[hexInput]" id="HexInput1" value="h1">
<input onclick="update(this.value);" type="radio" name="data[hexInput]" id="HexInput2" value="h2">
<input onclick="update(this.value);" type="radio" name="data[hexInput]" id="HexInput3" value="h3">

我想你在找这样的东西

尝试替换更改以单击