/    Sign up×
Community /Pin to ProfileBookmark

lossing data when returning to the form

H, guys.

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

[code=php]

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

?>

[/code]

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.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 05.2003 — [font=arial][color=maroon]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.[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@ivanrdgzauthorSep 05.2003 — [i]Originally posted by Jona [/i]

[B][font=arial][color=maroon]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.[/color][/font]



[b][J]ona[/b] [/B]
[/QUOTE]


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

If instead of this
[code=php]
function winOpenSearchName() {
var newWindow = window.open(
'',
'popup',
'top=325, left=395, width=450,height=350,scrollbars=yes,'
);
}
[/code]


I use this:

[code=php]

function winOpenSearchName() {
alert( "Testing..." );
}
[/code]


then everything is fine.
Copy linkTweet thisAlerts:
@JonaSep 05.2003 — [font=arial][color=maroon]Perhaps your problem is different than the understanding I got from your original post.[/color][/font]

[b][J]ona[/b]
×

Success!

Help @ivanrdgz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...