|
|
|
พี่คับ ถามเรื่องโค๊ด login คับ ทำไมพอเปลี่ยน button เป็นรูปแล้ว login ไม่ได้คับ |
|
|
|
|
|
|
|
คือ พอเปลี่ยน button เป็นรูป
<input name="btnLogin" type="image" src="img/log.png" id="btnLogin" OnClick="JavaScript:doCallAjax();" value="Login">
แล้ว login ไม่ได้คับ แต่พอทำ button แบบปกติ ก้อ login ได้ปกติคับ
Code (PHP)
<html>
<head>
<title>เข้าสู่ระบบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax() {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'check_log1.php';
var pmeters = "tUsername=" + encodeURI( document.getElementById("txtUsername").value) +
"&tPassword=" + encodeURI( document.getElementById("txtPassword").value );
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'sucses.php';
}
else
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
<body>
<h1>Login Form</h1>
<form name="frmMain">
<span id="mySpan"></span>
<table width="327" border="1">
<tr>
<th width="73">
<div align="left">อีเมล์</div></th>
<th width="238" align="left" ><input type="text" name="txtUsername" id="txtUsername" size="20"></th>
</tr>
<tr>
<th width="73">
<div align="left">รหัสผ่าน</div></th>
<th align="left"><input type="password" name="txtPassword" id="txtPassword" size="20"></th>
</tr>
<tr>
<th width="73">
</th>
<th align="left"><input type="checkbox" name="checkbox" id="checkbox">ให้ฉันอยู่ในระบบต่อไป</th>
</tr>
</table>
<br>
<input name="btnLogin" type="image" src="img/close.png" id="btnLogin" OnClick="JavaScript:doCallAjax();" value="Login">
</form>
</body>
</html>
Tag : PHP, HTML/CSS, JavaScript, Ajax
|
|
|
|
|
|
Date :
2013-07-11 17:08:08 |
By :
บ้านนอกคับป๋ม |
View :
749 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คิดว่าไม่น่าจะเกี่ยวกับตัวนี้ครับ
|
|
|
|
|
Date :
2013-07-12 11:03:08 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วคับพี่ๆ
ผมก้อไม่ทราบเหมือนกับคับพี่ว่าเกี่ยวหรือไม่เกี่ยวแต่ผมแก้ปัญหาโดยการกำหนด css ไห้มัน ดังนี้คับเผื่อคนที่เจอปัญหาเหมือนผม
ขั้นแรกก้อกำหนด css ก่อน
.bl{
width:81px;
height:33px;
background-image:url(img/login.png);
border:hidden;}
สำหรับ button ก้อ ดังนี้
<input name="btnLogin" type="button" class="bl" id="btnLogin" OnClick="JavaScript:doCallAjax();">
ประมาณนี้คับผม
|
ประวัติการแก้ไข 2013-07-13 11:20:06
|
|
|
|
Date :
2013-07-13 11:19:07 |
By :
บ้านนอกคับป๋ม |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|