Click to See Complete Forum and Search --> : lossing data when returning to the form


ivanrdgz
09-05-2003, 10:05 AM
H, guys.

I have a form width a text box, a link and a submit button. Here is the code (a simple example):




<html>
<head>
<title>TEST</title>

<script language="JavaScript">


/*==========================================================/
/ WinOpenSearchName - Open a new window for searchin CSTMR /
/ by Customer Name /
/==========================================================*/
function winOpenSearchName() {
var newWindow = window.open(
'',
'popup',
'top=325, left=395, width=450,height=350,scrollbars=yes,'
);
}

</script>

</head>

<center><h5>TESTING...</h5>

<form action="test.php" method="POST" name="frmMain">
<tr>
<td>&nbsp Customer Number:</td>
<td>&nbsp <input type=text name="CustomerNumber" maxlength=15>
<a href="#" onclick="winOpenSearchName();">[?]</a><br>
</td>
<tr>
<td align="center" colspan="2"><br>
<input align="center" type=submit value=" < OK > ">
</td>
</tr>
</table>
</form>

</center>

</body>


TEST.PHP

<?php

$CustomerNumber = $_POST['CustomerNumber'];

echo "Customer Number: " . $CustomerNumber;

?>



If we input some text into the text box and then we press the submit button, the TEST.PHP is prcoccessed and opened in another window. When you press the back button (IE) the entered text is still there, in the text box. Now if before you submit the form, you click on the link, and then submit the form, when you return back to it, the text box is empty. This is the problem. Any advices, sugestions?

Thanks.

Jona
09-05-2003, 01:40 PM
When the form is submitted (onsubmit), set the value to a variable in JavaScript, then when the person selects the form-window again after clicking the link (window.onfocus), set the value of the textbox to what the variable is.

[J]ona

ivanrdgz
09-05-2003, 02:38 PM
Originally posted by Jona
When the form is submitted (onsubmit), set the value to a variable in JavaScript, then when the person selects the form-window again after clicking the link (window.onfocus), set the value of the textbox to what the variable is.

[J]ona

It doesn't help. But I would like to know why this is happening?
If instead of this

function winOpenSearchName() {
var newWindow = window.open(
'',
'popup',
'top=325, left=395, width=450,height=350,scrollbars=yes,'
);
}


I use this:



function winOpenSearchName() {
alert( "Testing..." );
}


then everything is fine.

Jona
09-05-2003, 04:36 PM
Perhaps your problem is different than the understanding I got from your original post.

[J]ona