2016-08-18 4 views
0

文書がロードされたときに値を変更したいフォームに2つの入力があります。文書のロード後に入力 "変更"イベントまたは値を処理できません

これは私のコードです:

<?php 
$base = dirname(dirname(__FILE__)); 
include($base."/include/db.php"); 
?> 
<!DOCTYPE html> 
<html> 

<head> 

    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 

    <title>eMail Stationery | Installation for iPhone/iPad</title> 

    <link href="../css/bootstrap.min.css" rel="stylesheet"> 
    <link href="../font-awesome/css/font-awesome.css" rel="stylesheet"> 

    <link href="../css/plugins/steps/jquery.steps.2.css" rel="stylesheet"> 

    <link href="../css/animate.css" rel="stylesheet"> 
    <link href="../css/style.css" rel="stylesheet"> 
</head> 

<body class="gray-bg"> 

    <div class=""> 
     <center> 
      <img src="../img/esignia.png"> 
      <h3>iPhone/iPad Installation</h3> 

      <p>Follow the steps provided to install your signature</p> 
     </center> 
    </div> 
    <div id="wizard"> 
     <h3>Enter your details</h3> 
     <section> 
      <center> 
       <div class="row"></div> 
       <p><h2>Enter your details</h2></p> 
       <p>Enter your email address and unique pin number into the fields below to receive an email with a link to your signature.</p> 
       <div class="row"> 
        <div class="col-lg-4"></div> 
        <div class="col-lg-4"> 
         <form id="submitForm" method="post"> 
          <center> 
           <div class="form-group"> 
            <input id="email" name="email" type="email" placeholder="Email address" class="form-control" required> 
           </div> 
           <div class="form-group"> 
            <input id="pin" name="pin" type="number" placeholder="Unique PIN" class="form-control" required> 
           </div> 
           <button class="btn btn-success">Submit</button> 
           <p> 

           </p> 
          </center> 
         </form> 
        </div> 
       </div> 
      </center> 
     </section> 
     <h3>Copying your signature</h3> 
     <section> 
      <center> 
       <p><h2>Copying your signature</h2></p> 
       <p>Once you have followed the link we provided in the email, you will see your signature displayed fully on your device's web browser.</p> 
       <p>Simply highlight all of your signature and copy it to your device's clipboard as demonstrated below.</p> 
       <p><img src="../img/install/iphone_2.png" width="320px" height="480px"></p> 
      </center> 
     </section> 
     <h3>Locating your signature settings</h3> 
     <section> 
      <center> 
       <p><h2>Locating your signature settings</h2></p> 
       <p>Great! We've copied your signature and it is now ready to be installed!</p> 
       <p>We just need to find your mail's signature settings.</p> 
       <p>These are located at <b>Settings -> Mail, Contacts, Calendars -> Signature</b> 
        <p><img src="../img/install/iphone_3.png" width="320px" height="480px"> 
         <img src="../img/install/iphone_4.png" width="320px" height="480px"></p> 
        </center> 
       </section> 
       <h3>Installing your signature</h3> 
       <section> 
        <center> 
         <p><h2>Installing your signature</h2></p> 
         <p>Now that we have your signature settings open, you'll find an empty box ready for your signature to be pasted.</p> 
         <p>So all you need to do now is paste what we copied earlier into the box.</p> 
         <p><img src="../img/install/iphone_5.png" width="320px" height="480px"></p> 
         <p>One final thing you'll need to do is give your phone a quick shake to undo any of the modifications that your device will attempt to make to your signature's HTML code.</p> 
         <p>This is necessary for your signature to appear <i>exactly</i> how it appeared when you opened it.</p> 
         <p><img src="../img/install/iphone.gif"></p> 
         <p class="text-navy"><b>Congratulations, you've now successfully installed your signature to your device!</b></p> 
        </center> 
       </section> 
      </div> 
     </div> 
    </div> 

    <!-- Mainly scripts --> 
    <script src="../js/jquery-2.1.1.js"></script> 
    <script src="../js/bootstrap.min.js"></script> 

    <script src="../js/plugins/steps/jquery.steps.js"></script> 

    <script> 
     $(document).ready(function() { 
      var email = getUrlParameter("email"); 
      var pin = getUrlParameter("pin"); 
      if(email != undefined && pin != undefined) { 
       $("#email").val(email); 
       $("#pin").val(pin); 
      } 
      $("#wizard").steps({ 
       headerTag: "h3", 
       bodyTag: "section", 
       transitionEffect: "slideLeft", 
       autoFocus: true 
      }); 
      $("#submitForm").submit(function() { 
       var email = $("input[name='email']").val(); 
       var pin = $("input[name='pin']").val(); 
       $.get("../api/installed.php", { 
        email: email, 
        pin: pin 
       }); 
      }); 
      $("a[href='#finish'").click(function() { 
       window.location.href = "index.php"; 
      }); 
     }); 
     var getUrlParameter = function getUrlParameter(sParam) { 
       var sPageURL = decodeURIComponent(window.location.search.substring(1)), 
       sURLVariables = sPageURL.split('&'), 
       sParameterName, 
       i; 

       for (i = 0; i < sURLVariables.length; i++) { 
        sParameterName = sURLVariables[i].split('='); 

        if (sParameterName[0] === sParam) { 
         return sParameterName[1] === undefined ? true : sParameterName[1]; 
        } 
       } 
      }; 
    </script> 

</body> 

</html> 

これは動作しません。

しかし、私はクロームのコンソールに同じコードを複製し、それは完全に動作します。私の唯一の前提は、これらのコントロールがドキュメントがロードされた後でBootstrap/jQueryで混乱している、または再作成されているということです。

しかし、私はどこで、なぜ、何をすべきかを理解できません。

+0

チェックする要素のあなたのIdsを変更しようと動作しない場合は、コード

$(window).load(function() { var email = getUrlParameter("email"); var pin = getUrlParameter("pin"); if(email != undefined && pin != undefined) { $("#email").val(email); $("#pin").val(pin); } } 

の下に使用してみてください文書準備ハンドラで '' 'が欠落しているのとは別に)うまく動作するはずですが、これは単に質問のタイプミスであると仮定しています。 'email'と' pin'が正しく設定されていることを確認しましたか?コンソールにエラーがありますか?ページが読み込まれたときにDOMで '#email'と'#pin'要素が利用できるのですか?問題の例を示すことができますか? –

+0

コード全体を更新しました。見てみましょう。 – ThePerplexedOne

答えて

-1

この可能性があるため、準備ができていないDOMのまだあなたが持っているどのような他の要素との競合を乗り切るか

+0

それはうまくいくようでした。しかし、私のコードも動作するはずですか?意味がありません。 – ThePerplexedOne

関連する問題