2

I am wondering if it is possible to to resubmit a form with a button click that calls up a javascript command.

So this is basically what I'm trying to do -
page 1: form; action = page2.php
page 2: generate a randomized list according to parameters set by page 1

I would like to place a button on page 2 so that on click, it would be as if the user has hit F5, and a new list would be generated with the same parameters.

I found a lot of help on Google with people trying NOT to get this to happen, but I'm not sure how to actually get it to happen.....

Thank you!

0

2 Answers 2

2

You could use location.reload(true); to refresh the page.

<button onclick="location.reload(true);">refresh</button>
Sign up to request clarification or add additional context in comments.

3 Comments

So because I'm getting the data submitted by the form on page 2, if I just use location.reload, my form processing script tells me that it has no data to handle. I've tried history.go(0), and location.reload etc all the usual refresh commands with Javascript, and it hasn't worked
@user866339 Did you tried set the parameter to true as my example showed?
@user866339 Pages with submitted variables that you want to be able to revisit is what $_GET was designed for. Submit the form with method="get".
0

you only need to use. location.reload() instead of location.reload(true). since this will not disable caching for the reload but using true as the parameter will.

here is the reference. How to refresh a page in jquery?

EDIT: why not just use hidden input field and preserve the values and fetch it anytime you want to?

1 Comment

@user866339 then why not use hidden input field for preserving and changing values in page2.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.