gpt4 book ai didi

php - 提交表格的问题

转载 作者:行者123 更新时间:2023-11-28 09:36:45 25 4
gpt4 key购买 nike

采用如下形式:

 <form name="myform" action="All.php" method="get">
<input type='text' id='tx' name='tx' value=''>
<td height="8" align="right" valign="middle"><a href="javascript: submitform('All')">All Cities</a> | <a href="javascript: submitform('Newyork')">Newyork</a> | <a href="javascript: submitform('Police')">Police</a></td></form>

<script type="text/javascript">
function submitform(val)
{
$("#tx").val(val);
document.myform.submit();
}
</script>

在 All.php 中:

 <form method="get" action="index1.php" id="frm1">
<select id="category" onchange="showSelected1();" style="width:150px">
<option></option>
<option value="1" <?php if($_GET["categoryText"] == "Marriages") echo "selected"; ?> >Marriages</option>
<option value="2" <?php if($_GET["categoryText"] == "Birthdays") echo "selected"; ?> >Birthdays</option></select>
<input type="hidden" id="categoryText" name="categoryText" value='<?= $_GET['categoryText']; ?>'/>

<select id="city" onchange="showSelected();" style="width:150px">
<option><?= $_GET['tx']; ?></option>
<option></option>
<option value="1" <?php if($_GET["cityText"] == "Newyork") echo "selected"; ?> >Newyork</option>
<option value="2" <?php if($_GET["cityText"] == "Police") echo "selected"; ?> >Police</option></select>
<input type="hidden" id="cityText" name="cityText" value='<?= $_GET['cityText']; ?>'/>
<input type="button" value="Submit" onclick="formSubmit()"/></form>
<script language="JavaScript" type="text/javascript">
<!--
function showSelected()
{
var selObj = document.getElementById('city');
var cityTextObj = document.getElementById('cityText');

var selIndex = selObj.selectedIndex;
cityTextObj.value = selObj.options[selIndex].text;
}
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
function showSelected1()
{
var selObj = document.getElementById('category');
var categoryTextObj = document.getElementById('categoryText');

var selIndex = selObj.selectedIndex;
categoryTextObj.value = selObj.options[selIndex].text;

}
//-->
</script>

意味着,从第一页内容填充到 All.php 中的表单本身。如果有人单击“提交”按钮而不更改选择城市,则在 All.php 中,它不会显示,也不会将城市值添加到 index1.php。这是为什么?

最佳答案

你可以试试

document.getElementById("myform").submit();

关于php - 提交表格的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12912369/

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