PHP使用子窗口中的单选按钮确定从子窗口向父窗口文本区域插入什么
PHP determining what to insert into parent window textarea from child window using radio buttons in child window
大家好,我是php的新手,想知道如何使用子窗口中的单选按钮确定从子窗口向父窗口文本区域插入什么。我该怎么做?如果有人能在这方面提供一些帮助,我将不胜感激。下面是代码。谢谢
父窗口:
<head>
<script type='text/javascript'>
window.onload = function()
{
document.getElementById('b1').onclick = openChild;
}
function openChild()
{
this.disabled = false;
xWinOpen('retrievemath.php');
}
var xChildWindow = null;
function xWinOpen(sUrl)
{
// Modify 'features' to suit your needs:
var features = "left=100,top=100,width=400,height=400,location=0,menubar=0," +
"resizable=1,scrollbars=1,status=0,toolbar=0";
if (xChildWindow && !xChildWindow.closed) {xChildWindow.location.href = sUrl;}
else {xChildWindow = window.open(sUrl, "myWinName", features);}
xChildWindow.focus();
return false;
}
</script>
<script src="ckeditor/ckeditor.js"></script>
</head>
<body>
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10" ></textarea>
<form>
<input type="button" id ="b1" onClick="myPopup2()" value="POP2!">
</form>
<p onClick="myPopup2()">CLICK ME TOO!</p>
</body>
子窗口:
<?php
include ('database_connection.php');
$dbConn = mysql_connect('localhost', 'root', '')
or trigger_error(mysql_error(), E_USER_ERROR);
// select the database for use
mysql_select_db('test', $dbConn);
$query_retrieve_expression = "SELECT * FROM math";
$queryResource = mysql_query($query_retrieve_expression, $dbConn) or die(mysql_error());
?>
<head>
<script type='text/javascript'>
window.onload = function()
{
document.getElementById('f1').onsubmit = sendToParent;
}
function sendToParent()
{
if (window.opener) {
var cta = document.getElementById('<?php echo $row['mathID']?>');
var pta = window.opener.document.getElementById('editor1');
pta.value = cta.value;
window.opener.focus();
}
return false;
}
</script>
</head>
<body>
<form action="retrievemath.php" method="post" id="f1">
<table class="hovertable">
<tr>
<th>Insert ?</th><th>Expression Name</th><th>Math Expression</th>
</tr>
<?php
while($row = mysql_fetch_assoc($queryResource))
{
?>
<tr>
<td><input type="radio" name="insert" id="<?php echo $row['mathID']?>" value="<?php echo $row['expressionname']?>" /> </td>
<td><?php echo $row['expressionname']; ?></td>
<td><?php echo $row['mathexpression']; ?></td>
</tr>
<?php
}
?>
</table>
<div class="submit">
<input type="submit" value="Insert" />
</div>
</form>
</body>
您可以获得文本区域的值,并像一样传入url
最新功能
function sendToParent()
{
var cta='';
var radio=document.getElementsByName("insert");
for(var i=0;i<radio.length;i++)
{
cta+=radio[i].value;
}
var pta = var pta = window.opener.document.getElementById("editor1");
pta.value = cta;
self.close();
}
您可以在子窗口中获得文本区域的值,如
echo $_GET['data'];
子窗口代码
<head>
<script type='text/javascript'>
function sendToParent()
{
var cta='';
var radio=document.getElementsByName("insert");
for(var i=0;i<radio.length;i++)
{
cta+=radio[i].value;
}
var pta =var pta = window.opener.document.getElementById("editor1");
pta.value = cta;
self.close();
}
</script>
</head>
<body>
<form action="retrievemath.php" method="post" id="f1">
<table class="hovertable">
<tr>
<th>Insert ?</th><th>Expression Name</th><th>Math Expression</th>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
</tr>
<?php
while($row = mysql_fetch_assoc($queryResource))
{
?>
<tr>
<td><input type="radio" name="insert" id="<?php echo $row['mathID']?>" value="<?php echo $row['expressionname']?>" /> </td>
<td><?php echo $row['expressionname']; ?></td>
<td><?php echo $row['mathexpression']; ?></td>
</tr>
<?php
}
?>
</table>
<div class="submit">
<input type="button" value="Insert" onclick="sendToParent();" />
</div>
</form>
</body>
相关文章:
- 在highcharts.js中向点弹出窗口动态添加文本
- 如何在弹出窗口中隐藏文本属性'It’传单上没有填写
- PHP使用子窗口中的单选按钮确定从子窗口向父窗口文本区域插入什么
- 如何在网站上创建仅显示文本的简单弹出窗口
- CKEditor从子窗口更新父文本区域
- 点击剑道网格的编辑,在剑道窗口中填充文本框/DDL
- 如何使文本框的高度与窗口的高度相同
- 与我的jquery弹出窗口和自动调整文本区域大小有冲突
- 如果通过字符串变量发送,HTML内部的子窗口将显示为文本
- IE8:模式弹出窗口中的文本输入不会;t显示键入的文本
- 为什么我的html弹出窗口显示我的函数的文本,而不是运行它们
- 如何使用chrome应用程序窗口动态调整文本区域的大小
- 从文本框中附加url,然后使用javascript打开新窗口
- 将文本框数据传递到JavaScript窗口.location.href
- 始终具有窗口高度的文本区域
- 弹出窗口中的文本区域不接受输入
- 如何通过弹出窗口获取输入并通过javascript/jquery将文本放入变量中
- 从父窗口获取 iframe 中文本框的值
- 如何将文本区域的内容发送到新窗口
- 信息窗口文本颜色更改