gpt4 book ai didi

php - 动态更改iframe的src内容

转载 作者:行者123 更新时间:2023-11-28 00:20:38 26 4
gpt4 key购买 nike

我正在制作一个包含搜索结果的页面。简述场景是我有一个登录页面,它将引导您到另一个页面(假设主页)该页面包含 1 个下拉框(和)、1 个文本框、1 个按钮和 1 个 iframe,其中包含我拥有的页面我的 table 。现在我有一个显示在该表上的用户列表,其标题为名字、姓氏和中间名,这是启动时显示的所有数据现在我从下拉框中选择了名字,然后输入我的名字应该结果过滤那些与我同名的人。我在我的表格页面上使用了一个过滤器,我在其中添加了参数,例如//localhost/test/table.php?fname=test

现在的问题是,iframe 应该是唯一一个可以改变我的主页的框架。现在,iframe src 将根据我在下拉框中选择的内容在点击时更改,正如我已经说过的,无需使用表单提交,并且值将基于文本框上的文本。如果可能,也不要在 src 链接上使用 http://。

好吧,我几乎完成了 onclick 的部分将使用此脚本更改 iframe 页面:

<script type='text/javascript'>
function goTo(){
top.table.location = 'http://localhost/test/home.php;
}
</script>

应该是这样的:

$dropdownvalue = dropdownselectedtext
$textvalue = valueoftextbox

//localhost/test/table.php?$dropdownvalue$textvalue

这是我的第一部作品。评论以便更好地理解。假设“#”后跟文本表示某个值。供引用。

$acct_no = "#LOG_IN_ID OF USER";

echo "<script type='text/javascript'>
function goTo(){
top.table.src = '#SOMEURLHERE';
}
</script>";

echo "<table border='0' align='center' bgcolor='#ffffff' width='800px'>
<tr>
<td style='padding-left:30px;padding-top:20px;'>
<h3>SELECTION TEST</h3>
</td>
<td align='right' style='padding-right:30px;' height='120px'>
<select name='filter' id='filter'>
<option value='fname'>fname</option>
<option value='lname'>lname</option>
<option value='mname'>mname</option>
</select>
<input type='text' value='Enter text here' id='textbox'>
&nbsp;
<input type='button' value='Search' onClick='goTo();'> //this should give me the filters e.g: #SOMEURLHERE.php?#selectedfiltervalue=#textboxvalue
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<iframe src='table.php?ref=$acct_no' name='table' width='730px' height='300px' frameborder='0'></iframe>
</td>
</tr>
</table>";

最佳答案

我建议您保留 <script> PHP 区域之外的容器。

<script type="text/js" language="javascript">
//Your function goes here
</script

<?php echo "<form name='someName' action='#'>
echo "<table border='0' align='center' bgcolor='#ffffff' width='800px'>
<tr>
<td style='padding-left:30px;padding-top:20px;'>
<h3>SELECTION TEST</h3>
</td>
<td align='right' style='padding-right:30px;' height='120px'>
<select name='filter' id='filter'>
<option value='fname'>fname</option>
<option value='lname'>lname</option>
<option value='mname'>mname</option>
</select>
<input type='text' value='Enter text here' id='textbox'>
&nbsp;
<input type='button' value='Search' onClick='javascript: return goTo(\"this.parent.filter.value, this.parent.textbox.value\");'> //this should give me the filters e.g: #SOMEURLHERE.php?#selectedfiltervalue=#textboxvalue
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<iframe src='' name='table' width='730px' height='300px' frameborder='0'></iframe>
</td>
</tr>
</table></form>";?>

您没有使用 <form>标记整个部分,因此管理字段很困难。另外,试试我在上一篇文章中定义的 javascript。

关于php - 动态更改iframe的src内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9173390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com