-1
的問題我想檢索郵件和密碼,並將它們顯示爲<p>
元素中的json格式。問題是,當我點擊提交,沒有任何反應..是我的代碼錯了嗎?json_encode
<html>
<head>
</head>
<body>
<script>
function myfunction() {
var mail = document.getElementById("mail1").value;
var pass = document.getElementById("password1").value;
//document.getElementById("ici").innerHTML = mail + " " + pass ;
tab['mail'] = mail;
tab['password'] = password;
var output = json_encode(tab);
document.getElementById("ici").innerHTML = output;
}
</script>
Mail: <input type="text" name="mail" id="mail1">
password: <input type="text" name="password" id="password1">
<button onclick="myfunction()" > submit</button>
<p>ici: <span id="ici"></span></p>
</body>
</html>
JavaScript沒有json_encode,這是PHP函數 – Almis
我的意思是在結束一個標籤代碼 。 –