表題の通りです。
なぜかcpImgという関数が定義されていないと出てしまいます。何故なのでしょうか?
html
1 1 <html> 2 2 <head> 3 3 {% load static %} 4 4 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 5 5 <script> 6 6 $(document).ready(function() { 7 7 $('#fname').on('click',function() { 8 8 $.ajax({ 9 9 'url':'/labels/cpImg', 10 10 'type':'POST', 11 11 'data':{ 12 12 'fname':$('#fname').val(), 13 13 }, 14 14 'dataType':'json', 15 15 'success':function(response){ 16 16 //alert(response.fname); 17 17 }, 18 18 }); 19 19 return false; 20 20 }); 21 21 }); 22 22 </script> 23 47 24 48 <script> 25 49 function imgClick(f){ 26 50 document.getElementById("fname") = f; 27 51 val target = document.getElementById("fname"); 28 52 target.click(); 29 81 } 30 84 </script> 31 42 </head> 32 85 33 44 <body> 34 45 35 41 36 87 <input type="hidden" class="ajax" id="fname" value=""> 37 88 <table> 38 89 {% for lin in out %} 39 90 <tr> 40 91 {% for j in lin %} 41 92 <td><img id="{{ j }}" src= "{{ j }}" width="20" height="20" onclick="imgClick('{{ j }}')"></td> 42 93 {% endfor %} 43 94 </tr> 44 95 {% endfor %} 45 96 </table> 46 97 47 98 </body> 48 99 49100 50101 51102 </html>
html
1(index):2234 Uncaught ReferenceError: imgClick is not defined 2 at HTMLImageElement.onclick
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。