2016-09-09 5 views
1

사용자로부터 암호를 가져 오는 대화 상자를 생성하려면 여기에 약간의 코드가 필요합니다.Jquery 대화 상자가 표시되지 않습니다

<html> 
<head> 
<script type="text/javascript" src="jquery.min.js"></script> 
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> 
<script src="http://code.jquery.com/jquery-1.10.2.js"></script> 
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 
</head> 

<body> 
<input type='button' id='btnDelete' name='btnDelete' value='Delete' onclick='deleteRecord(".$row['ID'].")'/> 
<div id="delete-dialog" style="display: none;" title="Delete Record"> 
    <label>Please type in admin's password:</label></br> 
    <input type='password' size='25' id='inpAdminPassword'/>   
</div> 
</body> 
</html> 

JS 어떻게 든

function deleteRecord(ID){ 
var answer = confirm("Are you sure you want to delete this record?"); 
if(answer == true){ 
    $("#delete-dialog").dialog("open"); 
    } 
} 

$(document).ready(function() { 
$("#delete-dialog").dialog({ 
    autoOpen: false, 
}); 

, 표시되지 않습니다 대화 상자에서 무엇을 누락해야합니까?

나는 또한이 코드를 포함 시키려고했지만 여전히 작동하지 않습니다.

$(document).ready(function() { 
$("#delete-dialog").dialog({ 
    autoOpen: false, 
}); 
$("#delete-dialog").dialog({ 
    modal: true, 
    autoOpen: false, 
    height: 255, 
    width: 300, 
    buttons: { 
     "Delete": function() { 
      var password = document.getElementById('sessionPW').value; 
      var adminpw = document.getElementById('inpAdminPassword').value; 
      alert(password); 
      if(password == adminpw){ 
       window.location = "deleteThreat.php?threatID="+ID; 
      } 
     }, 
     Cancel: function() { 
      $(this).dialog("close"); 
      } 
     } 
    }); 
}); 

답변

0

난 그냥 첫 번째 솔루션을 시도하고이 같은 확인을하고 나를 위해 작동 :

JS :

$("#delete-dialog").dialog({ 
     autoOpen: false, 
    }); 

    $("#open").click(function() { 

     if (confirm("are you sure?")) { 
      $("#delete-dialog").dialog("open"); 
     } 


    }); 

HTML :

  <div id="delete-dialog" style="display: none;" title="Delete Record"> 
       <label>Please type in admin's password:</label></br> 
       <input type='password' size='25' id='inpAdminPassword'/>   
      </div> 

      <button id="open" >Open</button> 
+0

당신이 넣어나요 CSS 코드 ? 대화 상자가 여전히 표시되지 않습니다. 준비 기능 안에 js 코드가 있습니까? – camille

+0

는 준비 함수 안에 들어 있지 않으므로 CSS를 넣지 않습니다. – AitorFDK

+0

여전히 T.T를 표시하지 않습니다. jquery-ui 버전은 어떻습니까? – camille

관련 문제