2014-01-23 3 views
-2

20 분 후에 설문 조사를 보내거나 보내지 않아야합니다. 자바 스크립트를 사용하려고합니다 :양식을 자동으로 전송합니다.

<html> 
    <head> 
    <script type="text/javascript"> 
    function send() { 
         setTimeout ("document.forms [0] submit().", 5000); 
    } 
    </ script> 
</ head> 
<body> 
    <form action="index2.html" method="get"> 
     <select name="sel" onchange="enviar()"> 
      <option> value="1"> 1 </ option> 
      <option> value="2"> 2 </ option> 
     </ select> 
     <input type="submit" /> 
    </form> 
</ body> 
</ html> 

팁이 있습니까?

답변

0

setTimeout의 구문과 양식 제출 코드가 올바르지 않습니다. ID를 추가하고 함수 구문을 수정하십시오. 또한 태그 구문에주의하십시오.

귀하의 코드는 다음과 같이 될 것이다 :

<html> 
<head> 
<script type="text/javascript"> 
    function send() { 

     setTimeout(function(){document.getElementById("myForm").submit();},5000); 
    } 
</script> 
</head> 
<body> 
    <form action="index2.html" id="myForm" method="get"> 
     <select name="sel" onchange="enviar()"> 
      <option value="1"> 1 </option> 
      <option value="2"> 2 </option> 
     </select> 
     <input type="submit" /> 
    </form> 
</body> 
</html> 
+0

감사합니다, 당신은 zf2 엔이 솔루션을 구현하는 방법을 알고? – juanitourquiza

+0

문서에서 볼 수 있듯이 정상적인 방법으로 양식을 만들 수 있습니다. http://framework.zend.com/manual/2.0/en/user-guide/forms-and-actions.html 자바 스크립트 부분 , phtml 파일의보기에서 직접 작성할 수 있습니다. –

관련 문제