l在同一個窗體上創建了兩個按鈕,當我單擊其中每個按鈕時,彈出一個新窗口。我會希望他們在同一個窗口中打開動作表單。在同一個窗口上動作的多個按鈕
在代碼塊中查找我的代碼。
在此先感謝
<?php
//Start session
session_start();
//Unset the variables stored in session
unset($_SESSION['SESS_FIRST_NAME']);
unset($_SESSION['SESS_LAST_NAME']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="Javascript">
<!--
function OnButton1()
{
document.loginform.action = "login_exec.php"
document.loginform.target = "_blank"; // Open in a new window
document.loginform.submit(); // Submit the page
return true;
}
function OnButton2()
{
document.loginform.action = "adminLogin.php"
document.loginform.target = "_blank"; // Open in a new window
document.loginform.submit(); // Submit the page
return true;
}
-->
</script>
<noscript>You need Javascript enabled for this to work</noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Document</title>
</head>
<body>
<?php
if(isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) &&
count($_SESSION['ERRMSG_ARR']
) >0) {
echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?>
<body bgcolor="green">
<form name="loginform" method="post">
<br/><br/><br/><br/><br/><br/><br/>
<table width="309" border="0" align="center" cellpadding="2" cellspacing="5">
<tr>
<td colspan="2">
<!--the code bellow is used to display the message of the input validation-->
</td>
</tr>
<tr>
<td><div align="right">Username</div></td>
<td><input name="username" type="text" /></td>
</tr>
<tr>
<tr>
<td><div align="right">Password</div></td>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><INPUT type="button" value="Login" name=button onclick="OnButton1();"><br/><br/>
<INPUT type="button" value="Click to Login as Admin" name=button onclick="OnButton2();"></td>
</tr>
</table>
</form>
</body>
</html>
我想我得到了答案http://www.w3schools.com/jsref/prop_form_target.asp – Guderz90