1

What's the easiest way to re-populate a form when the page is reloaded? Is there a script in jquery, php, or javascript/ajax that would achieve this?

If the submitted failed, I want the user to go back. My problem is all my CSS hovers and background-changes don't work via keyup.

4

1 回答 1

3

If you mean reloaded before it is submitted you will need to use JavaScript to capture and store the values in a cookie, or to the server using Ajax, and then refill the form on page load.

If you mean after it is submitted then will need to use PHP to re-populate the form with the submitted form values:

<input type="text" name="somefield" value="<?php if (isset($_POST['somefield'])) echo htmlspecialchars($_POST['somefield'], ENT_HTML5, 'utf-8'); ?>">
于 2012-04-25T01:37:23.957 回答