I have a php code here and I would like to create a "back" href to get me back to where I was before. Here's what I have:
<input type="submit" <a href="#" onclick="history.back();">"Back"</a> <html> <head></head> <body> <?php // get form selection $day = $_GET['day']; // check value and select appropriate item if ($day == 1) { $special = 'Chicken in oyster sauce'; } elseif ($day == 2) { $special = 'French onion soup'; } elseif ($day == 3) { $special = 'Pork chops with mashed potatoes and green salad'; } else { $special = 'Fish and chips'; } ?> <h2>Today's special is:</h2> <?php echo $special; ?> <input type="submit" <a href="#" onclick="history.back();">"Back"</a> </body> </html>
You can use the history. back() method to tell the browser to go back to the user's previous page. One way to use this JavaScript is to add it to the onclick event attribute of a button. Here, we create the button using a <form> element, containing an <input> element of the button type.
The <button> element is used to create an HTML button. Any text appearing between the opening and closing tags will appear as text on the button. No action takes place by default when a button is clicked. Actions must be added to buttons using JavaScript or by associating the button with a form.
Backspace key, the computer keyboard key that deletes the character(s) to the left of the cursor. Back closure, a means for fastening a garment at the rear.
<button onclick="history.go(-1);">Back </button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With