2012-06-29 2 views
2

라디오 버튼의 코드에 어떤 문제가 있습니까? SELECT/OPTION을 시도했을 때 작동합니다.ajax-php에서 라디오 버튼을 만드는 방법은 무엇입니까?

나는, 라디오 버튼의 두 그룹을 그 값을 얻을 요약하기 위해 노력하고있어. 하지만 라디오 버튼이 전혀 응답하지 않기 때문에 나는 이동할 수 없습니다.

<input type='radio' id='1' name='r' onclick='pieces('this.value')' 
     autocomplete='off' value='yes'>Yes 
<input type='radio' id='2' name='r' onclick='pieces('this.value')' 
     autocomplete='off' value='no'>No 

내 스크립트 : 여기

<script type='text/javascript'> 

    function pieces(str) 
    { 

     if (str=='') 
     { 
      document.getElementById(abc).innerHTML=''; 
      return; 
     } 

     if (window.XMLHttpRequest) 
     { 
      // code for IE7+, Firefox, Chrome, Opera, Safari 
      xmlhttp=new XMLHttpRequest(); 
     } 
     else 
     { 
      // code for IE6, IE5 
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
     } 

     xmlhttp.onreadystatechange=function() 
     { 
      if (xmlhttp.readyState==4 && xmlhttp.status==200) 
      { 
       document.getElementById(abc).innerHTML=xmlhttp.responseText; 
      } 
     } 

     xmlhttp.open('GET','price.php?q='+str,true); 
     xmlhttp.send(); 

    } 
</script> 

답변

2

수정 된 스크립트입니다

은 내 양식에 입력합니다. 입력 :

여기
<input type='radio' id='1' name='r' onclick="pieces(this.value);" 
     autocomplete='off' value='yes'>Yes 
<input type='radio' id='2' name='r' onclick="pieces(this.value);" 
     autocomplete='off' value='no'>No 

은 JS 스크립트입니다 :

function pieces(str) 
    { 

     if (str=='') 
      { 
      document.getElementById("abc").innerHTML='Choose something'; 
      return; 
      } 

     if (window.XMLHttpRequest) 
      {// code for IE7+, Firefox, Chrome, Opera, Safari 
      xmlhttp=new XMLHttpRequest(); 
      } 
      else 
       {// code for IE6, IE5 
       xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
       } 

     xmlhttp.onreadystatechange=function() 
      { 
      if (xmlhttp.readyState==4 && xmlhttp.status==200) 
       { 
       document.getElementById("abc").innerHTML=xmlhttp.responseText; 
       } 
      } 

     xmlhttp.open('GET','hey.php?q='+str,true); 
     xmlhttp.send(); 

    } 

날 어떤 확률값 경우를 알려주십시오.

Jasminder 작동

+0

덕분에 ... 당신이 최대 - 투표, 작동하는 경우 : –

+1

을 내 후속 질문에 답하고 정답 @jasminder 표시 할 수 있기를 바랍니다. 새로운 질문을하고 답안으로 후속 질문을 게시하지 마십시오. –

관련 문제