我动态加载了一个页面。在该页面中,我有两个div
具有所需的值,或者数据显示在一个div
或iframe
中,并且使用POST将值传递给另一个应该反映在另一个div
中的文件或者iframe
结果。
请帮我解决这个问题.... 谢谢。
以下是我的示例代码
main.html中
<html>
<head>
</head>
<body>
<div id="leftbar" style="background-color:#eeeeee;width:400px;height:1000px;float:left;position:absolute;">
<iframe src="form1.html" width="1050px" height="1500px" seamless></iframe>
</div>
<div id="container" style="background-color:#FFD700;height:1000px;width:990px;float:right;">
<iframe src="process.php" name="content" width="1050px" height="1500px" seamless></iframe>
</div>
</body>
</html>
form1.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello!</title>
</head>
<body>
<form name="myform" action="process.php" method="POST" >
<input type="hidden" name="check_submit" value="1" />
Choose the colors: <br>
<input type="checkbox" name="Colors[]" value="green" checked="checked" onclick="document.forms.myform.submit();"/> Green<br>
<input type="checkbox" name="Colors[]" value="yellow" onclick="document.forms.myform.submit();" /> Yellow <br>
<input type="checkbox" name="Colors[]" value="red" onclick="document.forms.myform.submit();"/> Red <br>
<input type="checkbox" name="Colors[]" value="gray" onclick="document.forms.myform.submit();" /> Gray <br>
<br /><br />
</form>
</body>
</html>
process.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello!</title>
</head>
<body>
<?php
if (array_key_exists('check_submit', $_POST)) {
if (isset($_POST['Colors']) ) {
$_POST['Colors'] = implode(', ', $_POST['Colors']);
}
echo "Colors you chose: {$_POST['Colors']}";
}
?>
</body>
</html>
答案 0 :(得分:0)
将您的main.html
更改为main.php
,而使用表单名称而不是process.php
,只需使用main.php
<html >
<head>
</head>
<body>
<div id="leftbar" style="background-color:#eeeeee;width:400px;height:1000px;float:left;position:absolute;">
<iframe src="form1.html" width="1050px" height="1500px" seamless></iframe>
</div>
<?php
if (isset($_POST['Colors'])) {
if (array_key_exists('check_submit', $_POST)) {
$_POST['Colors'] = implode(', ', $_POST['Colors']);
}
echo "Colors you chose: {$_POST['Colors']}";
<div id="container" style="background-color:#FFD700;height:1000px;width:990px;float:right;">
<iframe src="process.php" name="content" width="1050px" height="1500px" seamless> </iframe>
</div>
<?PHP
}
?>
</body>
</html>