2017-02-25 4 views
0

私はこのコードを誰かの助けを借りて得て、#print_buttonをクリックすると実行するようにしました。何らかの理由で私はそれを働かせることができず、私はどこが間違っているのか分かりません。asp.net - ボタンは機能を実行しませんonclick

これはjQueryのです:

 $(document).ready(function() { 
     $('#Print_Button').click(function() { 


      var html2obj = html2canvas($('#form1')); 

      var queue = html2obj.parse(); 
      var canvas = html2obj.render(queue); 
      var img = canvas.toDataURL(); 

      window.open(img); 

     }); 

    }); 

とHTMLは、私のボタンの属性:私は間違っているつもりどこ

id="Print_Button" runat="server" value="Print" 

誰が提案してくださいことはできますか?

これは体のために完全なHTMLである:あなたのonclickイベントと間違って何もありません

<form id="form1" runat="server"> 


    <div class="header"> 

    <strong class="auto-style11"> 
     MCN PRINTOUT 

    </strong> 
     <img alt="Veolia Logo" class="logo" src="logo.png" /> 
     <input type="button" id="Print_Button" value="click me"/> 

    </div> 

     <div id="nav"> 
     <ul> 
      <li><a href="login.aspx">Home</a></li> 
      <li><a href="MCNForm.aspx">MCN Entry</a></li> 
      <li><a href="Search.aspx">MCN Search</a></li> 

     </ul> 
</div> 


      <div id ="main"> 
     <p id ="main_header"></p> 
     <p id ="mcn">DISPOSAL ADVICE/TRANSFER NOTE</p> 
     <p id="address"> 

     </p> 

     <table id="table_1""> 
      <tr> 
       <td class="auto-style12">MCN Ref No.</td> 
       <td> 
        <asp:TextBox ID="TextBox1" ReadOnly="True" runat="server" Width="116px"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td class="auto-style12">Date:</td> 
       <td> 
        <asp:TextBox ID="TextBox4" ReadOnly="True" runat="server" Width="116px"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td class="auto-style12">Time:</td> 
       <td> 
        <asp:TextBox ID="TextBox5" runat="server" ReadOnly="True" Width="116px"></asp:TextBox> 
       </td> 
      </tr> 
     </table> 

     <img alt="Logo" class="auto-style10" src="logo.png" /><div id ="form"> 
     <table id="main_table" class = "table table-bordered"> 
      <tr> 
       <td class="auto-style8">SITE:</td> 
       <td class="auto-style9"> 
        <asp:TextBox ID="TextBox6" runat="server" OnTextChanged="TextBox6_TextChanged" ReadOnly="True"></asp:TextBox> 
       </td> 
       <td class="auto-style4">HAULIER(CARRIER):</td> 
       <td> 
        <asp:TextBox ID="TextBox10" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td class="auto-style8">DESCRIPTION OF WASTE:</td> 
       <td class="auto-style9"> 
        <asp:TextBox ID="TextBox7" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
       <td class="auto-style4">DESTINATION:</td> 
       <td> 
        <asp:TextBox ID="TextBox9" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td class="auto-style8">EWC CODE:</td> 
       <td class="auto-style9"> 
        <asp:TextBox ID="TextBox8" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
       <td class="auto-style4">VEHICLE REGISTRATION:</td> 
       <td> 
        <asp:TextBox ID="TextBox11" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td class="auto-style8">QUANTITY:</td> 
       <td class="auto-style9"> 
        <asp:TextBox ID="TextBox13" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
       <td class="auto-style4">DRIVER NAME:</td> 
       <td> 
        <asp:TextBox ID="TextBox12" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td class="auto-style8">NOMINAL WEIGHT:</td> 
       <td class="auto-style9"> 
        <asp:TextBox ID="TextBox15" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
       <td class="auto-style4">SKIP ID:</td> 
       <td> 
        <asp:TextBox ID="TextBox16" runat="server" ReadOnly="True"></asp:TextBox> 
       </td> 
      </tr> 
      </table> 


      <table id="table_2" style="width:30%;"> 
       <tr> 
        <td>DUTY OF CARE:</td> 
        <td> 
         <asp:TextBox ID="TextBox14" runat="server" OnTextChanged="TextBox14_TextChanged"></asp:TextBox> 
        </td> 
       </tr> 
      </table> 
     </div> 

     <p id="tsandcs"> 

     </p> 

    </div>  



<div class="footer"> 



    <p id ="footer_menu">Menu</p> 
    <p id="copyright">© 2017 ...</p> 


</div> 




</form> 

+0

。アラートボックスが表示されるように警告してみてください。他の何かが間違っていると思います。 – neophyte

+0

@neophyte、上記のフルHTMLをご覧ください。以下の提案を試してもまだ動作しません。 – kehoewex86

+0

アラートは間違いなく@Sandeep Bhaskarの示唆どおりに動作するので、その後はJqueryでなければならないが、他の人がうまくいけばどこが間違っているのか分からない。 – kehoewex86

答えて

0

用入力タイプボタン

$(document).ready(function() { 
 
     $('#Print_Button').click(function() { 
 
      alert("Clicked"); 
 

 
      //your code here 
 

 
     }); 
 

 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
<input type="button" id="Print_Button" value="click me"/>

+0

こんにちは@Sandeep Bhaskar、あなたが提案したアラートは機能しますが、ここで別の投稿で他の人のために働いていた機能は動作しません。元の投稿に完全なHTMLを投稿しました。 – kehoewex86

関連する問題