我想在按下按钮时关闭页面。我使用脚本add_address.php
输出message
框中的电子邮件地址列表,我想将电子邮件地址输出到text
框中的send.php
框脚本
以下是add_address.php的代码:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Email Addresses...</title>
</head>
<body>
<form action="send.php" method="post">
<table>
<tr>
<td><textarea name="message" cols="50" rows="20"></textarea></td>
</tr>
<td colspan="2" align="left">
<input type="submit" name="send" value="Add Email" style="height:35px; width:100px">
</td>
</table>
</form>
</body>
以下是send.php的代码:
<?php
if (!empty($_POST['message']))
{
$emails = explode("\n", $_POST['message']); // explode textarea on a line break into an array
$email_str = implode(", ", $emails); // take each of the emails and implode together with the ,
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send Email</title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<form action="pr_send.php" method="POST">
<table>
<!-- <tr>
<td>From:</td>
<td><input type="text" name="from"></td>
</tr> -->
<tr>
<td><input type="button" name="to" value="" style="height:24px; width:24px; background:url('addressbook.png'); border:none;" onClick="Popup()"> To:</td>
<td><input type="text" name="to" value="<?php if (!empty($email_str)) { echo $email_str; } ?>" style="height:15px; width:650px"></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" style="height:15px; width:650px"></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name="message" cols="90" rows="20"></textarea></td>
</tr>
<tr>
<td colspan="2" align="left">
<input type="submit" name="send" value="" style="height:35px; width:100px; background:url('send.png'); border:none">
</td>
</tr>
</table>
</form>
</body>
<script type="text/javascript">
function Popup()
{
window.open("add_address.php", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=500, width=400, height=400");
}
</script>
</html>
我的代码段显示了什么,它只允许我输出message
框中的电子邮件地址列表,它将重定向到send.php
页面以输出电子邮件地址列表。 text
框没有关闭它。
答案 0 :(得分:0)
您不应该使用window.open,而应该使用其他方式,例如使用Jquery和CSS创建弹出函数或使用已创建的库(tagit.js):
答案 1 :(得分:0)
我可能不在基础,但我认为你想要一个只有javascript的对话框来获取你的电子邮件地址。你可以搜索一下。我想出了这个模型(对我来说是一个开始):
编辑:扩展模型以回答评论。
<!DOCTYPE html><html><!-- HTML5 -->
<!-- - - - - head - - - - --><head>
<meta charset="UTF-8">
<title>..</title>
<!-- - - - - script - - - - --><script type="text/javascript">
function opendialog() {
var elt1 = document.getElementById("dialogid");
elt1.style.display = "inline";
}
function closedialog() { // process the dialog data
var elt1 = document.getElementById("iddialog");
var elt2 = document.getElementById("idbase");
elt2.value = elt1.value;
var elt3 = document.getElementById("dialogid");
elt3.style.display = "none";
}
</script>
<!-- - - - - style - - - - --><style type="text/css">
td:nth-child(1) { width:100px; }
td:nth-child(2) { width:400px; }
table input { width:100%; }
#dialogid { display: none; background: #fee;
position: fixed; left: 200px; top: 100px; width: 800px; height: 50px; }
</style>
</head>
<!-- - - - - body - - - - --><body><div id="bodydiv">
<table><tr>
<td></td><td><button type="button" onclick="opendialog();">Opendialog</button></td>
</tr><tr>
<td>To:</td><td><input type="text" id="idbase" /></td>
</tr><tr>
<td>Subject:</td><td><input type="text" /></td>
</tr><tr>
<td>Message:</td><td><textarea cols="90" rows="20"></textarea></td>
</tr><tr>
<td></td><td><button type="button">Sendmail</button></td>
</tr></table>
<div id="dialogid">
This is the dialog<br />
To: <input type="text" id="iddialog" />
<button type="button" onclick="closedialog();">Closedialog</button>
</div>
</div></body></html><!-- - - - - end of it all - - - - -->