简体   繁体   中英

Javascript PHP a pop up image appear when click on search, after close image display search results

I want to do a 'pop up image' using javascript to display a simple user guide image, after the user click on search the image will pop up, to give them a better understanding of the results. So when the user close the image they will be link to results.php. Sorry that I can't provide any useful javascript codes, because those codes that I've found from the internet is too long. And I'm very noob at javascript.

Save Post->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");
}
}
?>

Search Form (loan amount field)

<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>

in the popup page you can put in section:

<script type="text/javascript"> 
window.onclose=goToResults

 function goToResults(){
      //do the parent go to results.php
      parent.location="results.php";
} 
</script>

if its a form to be submitted you can point a function on parent and that function can submit the form:

in popup:

function goToResults(){
//do the parent go to results.php
parent.submitForm();
} 

in page:

function sumbitForm(){
      form_to_submit=document.getElementById("FORM_ID");
      form_to_submit.submit();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM