I would like to keep my form fields filled after I press the "submit" button. I noticed that when the page loads, my fields are cleared, and I'd like them to keep the data I provided before. (I feel like browsers used to do this by default.) Is there an easy way to do this?
Right now, I'm using the GET action so I can see all my data, and my page is a plain HTML file, to keep it simple. I know I can read all the file using $_GET['whatever'] and place the values back in the form fields, but I feel there's an easier way which can keep all fields in the form complete.
I've also tried a couple of session tricks but they didn't work. I also tried removing excess, like my labels, and that didn't do anything.
My page is straighforward right now. I have a basic form:
<form name="filter" method="get" action="">
<input type="text" name="s" value="" /><br />
<select id="location">
<option value="school">School</option>
<option value="work">Work</option>
<option value="home">Home</option>
</select><br />
<label><input type="checkbox" name="cat" value="0" /> Category1</label><br />
<label><input type="checkbox" name="cat" value="1" /> Category2</label><br />
<label><input type="checkbox" name="cat" value="2" /> Category3</label><br />
<input type="submit" value="Go ➧" />
</form>
I'll provide some values, submit (which loads the page again), and they'll be blank. It passes my variables to the URL just fine, but I'd like the fields to remain populated.