Php 从父窗口提交Iframe表单 函数submitiframeform(){ window.frames['frame1'].document.forms['fypassign'].submit(); }
上面是committee_assign.php的主页名 下面是名为committee_assign1.php的iframe的页面Php 从父窗口提交Iframe表单 函数submitiframeform(){ window.frames['frame1'].document.forms['fypassign'].submit(); },php,javascript,iframe,Php,Javascript,Iframe,上面是committee_assign.php的主页名 下面是名为committee_assign1.php的iframe的页面 <iframe id="frame1" name="frame1" align="center" src="committee_assign1.php" height="400" width="700"> </iframe> <center><inpu
<iframe id="frame1" name="frame1" align="center" src="committee_assign1.php" height="400" width="700">
</iframe>
<center><input onClick="submitiframeform(); return false;" type="button" name="submit" value="Submit" />
<script type="text/javascript">
function submitiframeform(){
window.frames['frame1'].document.forms['fypassign'].submit();
}
</script>
在名为submit:
if(设置($\u POST['submit'])
您必须检查以下内容:
if(isset($\u POST))
您正在检查提交是否已发布,但您没有名为提交的输入。添加一个名为submit的输入,并检查post submit是否存在。如果不想看到额外的输入,可以将其隐藏
if($_POST['submit'])正在检查POST数组中是否有键为'submit'的值。$\u POST数组中的所有键和值分别是表单元素的名称和值。感谢您的回复。我改为if(isset($\u POST)),但iframe显示为空白,并且似乎在执行某些操作,因为我的鼠标光标一直在闪烁。。你知道会发生什么吗?我不知道你想做什么,但问题应该在这里:while($continue==FALSE){if(isset($\u POST['id.'.$I]){$fypcomm=$\u POST['fypcomm.$I];$user=$\u POST['id.$I];$sql=mysql\u查询(“更新讲师集LectFypCommittee='$fypcomm',其中LectID='$user')或die(mysql_error());mysql_query($sql);}else{$continue=TRUE;}$i++}echo(“window.location.href='../committee/committee_assign1.php'));您好,这是我在下面的表单中向数据库输入值的部分。在我放入Iframe之前,它就工作了。有什么办法解决这个问题吗?对不起,我不明白。您介意向我解释更多吗?我是PHP的新手。在普通html表单中,有一个名为submit的submit按钮。这就是您的代码(如果(isset))的内容($\u POST[submit])正在检查。$\u POST中的所有值都是来自表单输入的值。键是表单输入名称。因此,如果您有一个具有名称操作和值submitform的输入,$\u POST['operation']如果表单已提交,则会将值提交表单。哦..我理解你的意思..有一些值$\u POST..你有解决此问题的示例吗?应该用一些值替换代码的上半部分,但它是什么?请告诉我。TQYou并在表单中添加一个带有名称和val的隐藏输入您选择的ue。然后将if($\u POST['submit'])替换为if($\u POST['hidden input name']==“hidden input value”)。这确保您对正确的表单数据进行处理。
<?php
include '../database.php';
include 'valid_login.php';
if(isset($_POST['submit'])) {
$continue = FALSE;
$i = 0;
while ($continue == FALSE) {
if (isset($_POST['id_'.$i])) {
$fypcomm = $_POST['fypcomm_'.$i];
$user = $_POST['id_'.$i];
$sql = mysql_query(" UPDATE Lecturer SET LectFypCommittee = '$fypcomm' WHERE LectID = '$user' ")
or die(mysql_error());
mysql_query($sql);
} else
{$continue = TRUE;}
$i++;
}
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.location.href='../committee/committee_assign1.php'
</SCRIPT>");
}
?>
<head>
</head>
<body>
<form id="fypassign" name="fypassign" method="post" action="" target="_self" onSubmit="">
<?php
$counter = 0;
echo "<table class ='box'>";
echo "<thead>";
echo "<tr>";
echo "<th align='left' valign='top'>"."Lecturer Name"."</th>";
echo "<th align='left' valign='top'>"."FYP Committee"."</th>";
echo "</tr>";
$sql = mysql_query(" SELECT * FROM Lecturer ORDER BY LectFypCommittee DESC, LectName ASC ") or die(mysql_error());
while($info = mysql_fetch_assoc($sql)) {
$idcount = "id_".$counter;
echo "<input type='hidden' name='$idcount' id='$idcount' value={$info['LectID']} />";
echo "<tr>";
echo "<td>";
echo $info['LectName'];
echo "</td>";
echo "<td>";
$formname = "fypcomm_".$counter;
echo "<select name='$formname'>";
//to convert the flag value to user understandable language
if ($info['LectFypCommittee'] == '0'){
$dbfyp = 'No';
}
else $dbfyp = 'Yes';
echo "<option selected='selected' value='{$info['LectFypCommittee']}'>".$dbfyp."</option>";
if ($info['LectFypCommittee'] == '0'){
echo "<option value='1'>".'Yes'."</option>";
}
else echo "<option value='0'>".'No'."</option>";
echo "</select>";
echo "</td>";
echo"</tr>";
$counter++;
}
echo "</table>";
?>
</form>
</body>