2012-12-29 5 views
0

나는 cakephp에 의해 생성 된 radiobuttons 그룹을 가지고 있습니다.라디오 버튼 그룹, 변경 이벤트?

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

그룹의 라디오 버튼 중 하나가 선택되었는지 확인하는 방법이 있습니까? 변화 사건이나 뭐 때문에?

특정 버튼을 사용하지만 그룹과 함께하는 방법은 알고 있습니다. 특정 단추의 경우이 Js 도우미를 사용하십시오.

$this->Js->get('HexInput2')->event('change', $this->Js->request(array(
      'controller' => 'designer', 
      'action' => 'test', 
       ), array(
      'update' => '#resultDiv', 
      'async' => true, 
      'method' => 'post', 
      'dataExpression' => true, 
      'data' => $this->Js->serializeForm(array(
       'isForm' => false, 
       'inline' => true 
      )) 
     )) 
); 
+0

시도처럼 뭔가를 찾고 생각 클릭으로 변경 –

+0

jQuery를 사용하고 있습니까? –

답변

1

각 라디오 단추에 대한 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">