2016-06-06 4 views
0

지형 퀴즈를 프로그래밍하려고하는데 작동하지 않는 것 같습니다. '제출'버튼을 클릭 할 때마다 InvalidArgumentError: Failed due to illegal value in property: 0이 인쇄됩니다. 왜 이런 생각이 들었 니? 미리 감사드립니다.InvalidArgumentError : 속성 값이 잘못되었습니다 : 0


HTML :

<!DOCTYPE html> 
 
    <html> 
 
     <head> 
 
      <base target="_top"> 
 
      <script> 
 
       function send() { 
 
        var q1 = document.getElementById("q1").value; 
 
        var q2 = document.getElementById("q2").value; 
 
        var q3 = document.getElementById("q3").value; 
 
        var q4 = document.getElementById("q4").value; 
 
        var q5 = document.getElementById("q5").value; 
 
        var q6 = document.getElementById("q6").value; 
 
        var q7 = document.getElementById("q7").value; 
 
        var q8 = document.getElementById("q8").value; 
 
        var Email = document.getElementById("EmailAddress"); 
 
        var Result = ("Results: 1. " + q1 + " 2. " + q2 + " 3. " + q3 + " 4. " + q4 + " 5. " + q5 + " 6. " + q6 + " 7. " + q7 + " 8. " + q8); 
 
        google.script.run.send(Email, Result); 
 
       } 
 
      </script> 
 
      <script src="https://ws.sharethis.com/button/buttons.js"> 
 
      </script> 
 
      <script> 
 
       stLight.options({ 
 
       \t publisher: "a788dcd1-6dfb-49ee-ba6c-3b6822d69fd8", 
 
       \t doNotHash: false, 
 
       \t doNotCopy: false, 
 
       \t hashAddressBar: false 
 
       }); 
 
      </script> 
 
      <style> 
 
       .myButton { 
 
        -moz-box-shadow: inset 0px 39px 0px -24px #e67a73; 
 
        -webkit-box-shadow: inset 0px 39px 0px -24px #e67a73; 
 
        box-shadow: inset 0px 39px 0px -24px #e67a73; 
 
        background-color: #e4685d; 
 
        -moz-border-radius: 4px; 
 
        -webkit-border-radius: 4px; 
 
        border-radius: 4px; 
 
        border: 1px solid #ffffff; 
 
        display: inline-block; 
 
        cursor: pointer; 
 
        color: #ffffff; 
 
        font-family: Arial; 
 
        font-size: 15px; 
 
        padding: 6px 15px; 
 
        text-decoration: none; 
 
        text-shadow: 0px 1px 0px #b23e35; 
 
       } 
 
       .myButton:hover { 
 
        background-color: #eb675e; 
 
       } 
 
       .myButton:active { 
 
        position: relative; 
 
        top: 1px; 
 
       } 
 
       .myButton2 { 
 
        -moz-box-shadow: inset 0px -3px 7px 0px #29bbff; 
 
        -webkit-box-shadow: inset 0px -3px 7px 0px #29bbff; 
 
        box-shadow: inset 0px -3px 7px 0px #29bbff; 
 
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #2dabf9), color-stop(1, #0688fa)); 
 
        background: -moz-linear-gradient(top, #2dabf9 5%, #0688fa 100%); 
 
        background: -webkit-linear-gradient(top, #2dabf9 5%, #0688fa 100%); 
 
        background: -o-linear-gradient(top, #2dabf9 5%, #0688fa 100%); 
 
        background: -ms-linear-gradient(top, #2dabf9 5%, #0688fa 100%); 
 
        background: linear-gradient(to bottom, #2dabf9 5%, #0688fa 100%); 
 
        filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#2dabf9', endColorstr='#0688fa', GradientType=0); 
 
        background-color: #2dabf9; 
 
        -moz-border-radius: 3px; 
 
        -webkit-border-radius: 3px; 
 
        border-radius: 3px; 
 
        border: 1px solid #9591ff; 
 
        display: inline-block; 
 
        cursor: pointer; 
 
        color: #ffffff; 
 
        font-family: Arial; 
 
        font-size: 15px; 
 
        padding: 6px 23px; 
 
        text-decoration: none; 
 
        text-shadow: 0px 1px 0px #263666; 
 
       } 
 
       .myButton2:hover { 
 
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0688fa), color-stop(1, #2dabf9)); 
 
        background: -moz-linear-gradient(top, #0688fa 5%, #2dabf9 100%); 
 
        background: -webkit-linear-gradient(top, #0688fa 5%, #2dabf9 100%); 
 
        background: -o-linear-gradient(top, #0688fa 5%, #2dabf9 100%); 
 
        background: -ms-linear-gradient(top, #0688fa 5%, #2dabf9 100%); 
 
        background: linear-gradient(to bottom, #0688fa 5%, #2dabf9 100%); 
 
        filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#0688fa', endColorstr='#2dabf9', GradientType=0); 
 
        background-color: #0688fa; 
 
       } 
 
       .myButton2:active { 
 
        position: relative; 
 
        top: 1px; 
 
       } 
 
      </style> 
 
     </head> 
 
     <body> 
 
      <font face="Verdana"> 
 
       <h1> 
 
        Geography Quiz 
 
       </h1> 
 
       <br/> 
 
       <br/> 
 
       Your teacher's email address: 
 
       <input type="text" id="EmailAddress"/> 
 
       <br/> 
 
       <br/> 
 
       <b> 
 
        Questions 
 
       </b> 
 
       <br/> 
 
       <br/> 
 
       Q (1): Which state has a climate suitable for growing citrus fruits—California or Maine? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q1"/> 
 
       <br/> 
 
       <br/> 
 
       Q (2): The North Atlantic current brings warm waters from the tropics to the west coast of which continent? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q2"/> 
 
       <br/> 
 
       <br/> 
 
       Q (3): Which Canadian province produces more than half of the country's manufactured goods? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q3"/> 
 
       <br/> 
 
       <br/> 
 
       Q (4): To visit the ruins of Persepolis, an ancient ceremonial capital of Persia, you would have to travel to what present-day country? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q4"/> 
 
       <br/> 
 
       <br/> 
 
       Q (5): What is the term for a part of an ocean or sea that cuts far into the bordering landmass and may contain one or more bays? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q5"/> 
 
       <br/> 
 
       <br/> 
 
       Q (6): Which country has the world's largest Muslim population—Indonesia or Mexico? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q6"/> 
 
       <br/> 
 
       <br/> 
 
       Q (7): The Rio Hondo forms a boundary between Mexico and which other country? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q7"/> 
 
       <br/> 
 
       <br/> 
 
       Q (8): Which lake is on the border between Chad and Cameroon? 
 
       <br/> 
 
       A: 
 
       <input type="text" id="q8"/> 
 
       <br/> 
 
       <br/> 
 
       <button onclick="send(); document.write('Thanks! Your teacher will receive your results in an email.')" class="myButton"> 
 
        Submit 
 
       </button> 
 
       <br/> 
 
       <br/> 
 
       <br/> 
 
       <br/> 
 
       <span class='st_facebook_hcount'> 
 
       </span> 
 
       <span class='st_twitter_hcount'> 
 
       </span> 
 
       <span class='st_googleplus_hcount'> 
 
       </span> 
 
       <br/> 
 
       <br/> 
 
       <footer> 
 
        <font size="1px"> 
 
         Posted by: Yona Klatchko | Contact information: 
 
         <a href="mailto:[email protected]"> 
 
          [email protected] 
 
         </a> 
 
        </font> 
 
       </footer> 
 
      </font> 
 
     </body> 
 
    </html>


구글 - 애플 리케이션 - 스크립트의 doGet() 함수 :

function doGet() { 
    return(HtmlService.createTemplateFromFile('Index.html').evaluate().setTitle('Geography Quiz').setSandboxMode(HtmlService.SandboxMode.IFRAME)); 
} 

,

구글 - 애플 리케이션 - 스크립트 전송() 함수 : 당신의 send() 기능에

function send(Email, Result) { 
    MailApp.sendEmail(Email, Result); 
} 

+2

MCVE (http://stackoverflow.com/help/mcve)의 도움말 가이드를 살펴 보는 것이 좋습니다. 귀하의 코드에는 CSS, 많은 퀴즈 질문 등 문제 자체를 방해하는 세부 정보가 많이 포함되어 있습니다. 예를 짧게하면 사람들이 더 쉽게 도와 줄 수 있습니다. –

답변

1

, 당신은 추출하고 문자열 값 대신 이메일 DOM 요소를 보내는 :

var Email = document.getElementById("EmailAddress"); 반환 DOM 요소 .

변경이에 :

var Email = document.getElementById("EmailAddress").value; 

invalidArgumentError의 문제를 해결합니다.


다음 문제는 이메일을받지 못하게하는 것입니다. 당신은 두 개의 매개 변수를 전달하는

function send(Email, Result) { 
    MailApp.sendEmail(Email, Result); 
} 

있지만 documentation에서 보는 바와 같이, 세 번째 매개 변수는 선택 사항이 아니므로 몸과 세 번째 매개 변수를 전달해야합니다 코드에 있기 때문에 때문입니다.

MailApp.sendEmail(Email, Result, ""); 

빈 몸통으로 이메일을 보내드립니다.

+0

감사! 나는 아주 바보 같은 실수를 저질렀다. 나는 그 생각을하지 않았다는 것을 믿을 수 없다! – YonaTheYak

+0

문제 없음 .. 대답이 도움이된다면, 답변의 틱 버튼을 클릭하여 답변을 수락하고 질문을 닫을 수 있습니다. – MShoaib91

관련 문제