Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write the code for the back button?

Tags:

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>  
like image 423
tintincutes Avatar asked Sep 07 '10 14:09

tintincutes


People also ask

How do I code Back Button in 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.

How do I create a button code?

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.

What is the Back button called?

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.


1 Answers

<button onclick="history.go(-1);">Back </button> 
like image 126
GSto Avatar answered Oct 01 '22 06:10

GSto