我想使用javascript做一个“弹出图像”来显示一个简单的用户指南图像,用户点击搜索后图像会弹出,让他们更好地理解结果。因此,当用户关闭图像时,它们将链接到 results.php。抱歉,我无法提供任何有用的javascript代码,因为我从互联网上找到的那些代码太长了。而且我对 javascript 很菜鸟。
保存帖子-> session
<?php
$loan_amt = $_POST['loan_amt'];
if($_POST['search']){
if($_POST['loan_amt']=="" || $_POST['loan_tenure']==""){
$error = "Please fill up the mandatory fields";
}else{
session_start();
$_SESSION['property_type'] = $_POST['property_type'];
$_SESSION['property_status'] = $_POST['property_status'];
$_SESSION['loan_amt'] = $_POST['loan_amt'];
$_SESSION['loan_tenure'] = $_POST['loan_tenure'];
header("location:rates_result.php");
}
}
?>
搜索表单(贷款金额字段)
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="this.loan_amt.value=this.loan_amt.value.replace(/\,/g,'')">
<table width="400px">
<tr>
<td class="color1" width="130">Loan Amt (SGD)*:</td>
<td width="258" align="left">
<input type="text" style="width:150px;font-size:16px" onkeyup="format(this)" onchange="format(this)"
onblur="if(this.value.indexOf('.')==-1)this.value=this.value" name="loan_amt">
</td>
<td width="258" align="left"><input type="submit" class="buttonStyle" name="search" value="search" /></td>
</tr>
</table>
</form>
最佳答案
在弹出页面中,您可以放入以下部分:
<script type="text/javascript">
window.onclose=goToResults
function goToResults(){
//do the parent go to results.php
parent.location="results.php";
}
</script>
如果它是要提交的表单,您可以在父级上指向一个函数,并且该函数可以提交表单:
在弹出窗口中:
function goToResults(){
//do the parent go to results.php
parent.submitForm();
}
页面中:
function sumbitForm(){
form_to_submit=document.getElementById("FORM_ID");
form_to_submit.submit();
}
关于php - Javascript PHP点击搜索时出现弹出图像,关闭图像后显示搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11204779/