By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Making a BACK buntton work

P: 7
Hie

Could someone please help me I'm trying to make a back button and I'm trying not to make the button a submit button. The action or the redirection to another page is done using php and my code is as follows:

Expand|Select|Wrap|Line Numbers
  1. <link href="css/jobSheet.css" rel="stylesheet" type="text/css" />
  2. <?php
  3.  session_start();
  4. ?>
  5.  
  6. <html> 
  7. <head>
  8.  </head>
  9.   <body>
  10.   <?php
  11.     require_once('dbFunction.php');
  12.     ?>  
  13.  
  14.     <form method="post" action="returnToRedirectNewClientJobsheet.php" onSubmit="displayOldInfo()">
  15. <?php
  16. dbConnect();
  17.  
  18. $role = mysql_query("SELECT * FROM STATUS_DESC") or die(mysql_error());
  19. $staff = mysql_query("SELECT * FROM STAFF")
  20. ?>
  21.  
  22. <table width="75%" cellpadding="5" cellspacing="0" class="borderTop" align="center">
  23.     <td colspan="2" bgcolor="#FFCC00" align="center"><strong>New Client Jobsheet</strong></td>
  24.     <tr>
  25.  
  26.   <td align="left" width="65%" valign="top">
  27.         <table align="left" width="100%" cellpadding="5" cellspacing="0">
  28.  
  29.         <tr align="center" class="formHeader">
  30.           <td width="47%" bgcolor="#FFCC00"><strong>Client details</strong>
  31.         <td width="53%" bgcolor="#FFCC00"><strong>Job sheet details</strong>        </td>
  32.           </tr>
  33.           <tr>
  34.             <td valign="top" align="center"><table cellpadding="4" class="formText">
  35.                 <tr><td>Client name<td>
  36.                       <?=$_SESSION['firstName']; ?></td>
  37.                 <tr><td>Client Lastname<td>
  38.                       <?=$_SESSION['lastName']; ?></td>
  39.                 <tr><td>Client Title<td>
  40.                       <?=$_SESSION['client_title']; ?></td>
  41.                 <tr><td>Company name<td>
  42.                       <?=$_SESSION['company_name']; ?></td>
  43.                 <tr><td>Company code<td>
  44.                       <?=$_SESSION['company_code'] ?></td>
  45.                 <tr><td>Site address<td>
  46.                       <?=$_SESSION['Site_address']; ?></td>
  47.                 <tr><td>Postal Address<td>
  48.                       <?=$_SESSION['postal_address']; ?></td>
  49.                 <tr><td>Phone number<td>
  50.                        <?=$_SESSION['phone_number']; ?></td>
  51.                 <tr><td>E-mail<td>
  52.                        <?=$_SESSION['email_address']; ?></td>
  53.                 <tr><td>Website<td>
  54.                         <?=$_SESSION['website']; ?></td>
  55.                 </tr>    
  56.             </table>
  57.  
  58.             <td valign="top" align="center">
  59.  
  60.             <table cellpadding="3">
  61.                    <tr><td class="formText">Job Sheet Number
  62.                    <td class="formText">
  63.                       <?=$_SESSION['jobID']; ?></td>
  64.                 <tr><td class="formText">Date<td class="formText"><?=$_SESSION['date']; ?></td>
  65.                 <tr><td class="formText">Assigned to
  66.                   <td><?php
  67.                      $aStaffID = $_SESSION['assignedStaff'];
  68.                      $staffQuery= mysql_query("SELECT username FROM STAFF WHERE staffID ='$aStaffID' ")or die (mysql_error());
  69.                       $results = mysql_fetch_array($staffQuery);
  70.                       echo $results[0];
  71.                             ?></td>
  72.                 <tr><td class="formText">Assigned Date
  73.                   <td><?=$_SESSION['assingedDate']; ?>
  74.  
  75.                 <tr><td class="formText">Assigned Time
  76.                 <td>
  77.                        <?=$_SESSION['assignedTime'];
  78.                        ?>
  79.              </td>
  80.                 <tr><td>Status<td>
  81.                         <?=$_SESSION['status'];
  82.                         ?>
  83.                  </td>
  84.         </table>
  85.         <tr><td></td></tr>
  86.     <tr>
  87.         <td colspan="2" align="center" class="borderTop" bgcolor="#FFCC00"><span class="formHeader"> <strong>Request</strong></span></td></tr>
  88.         <tr>
  89.         <td colspan="2" align="center" class="borderTop" bgcolor="#FFCC00"><span class="formHeader">
  90.         <strong>Title :<?=$_SESSION['title']; ?>
  91.         </strong></span></td></tr>
  92.             <tr>
  93.           <td colspan="2" align="center"><textarea name="textarea" cols="70" rows="10" class="textAreaBorder">
  94.                        <?=$_SESSION['request']; ?>
  95.            </textarea></td></tr>
  96.            <tr>
  97.           <tr><td colspan="2" align="center" class="borderTop" bgcolor="#FFCC00">
  98.         <input type="reset" name="clear" value="&lt;&lt;Undo" class="button" >       
  99.         <input type="submit" name="submit" value="Continue&gt;&gt;" class="button">
  100.      </td></tr>
  101.       </table>
  102.       </td>
  103.   </tr>          
  104.  
  105. </table>
  106.       </td>
  107.   </tr>
  108.   </table>      
  109.  
  110. </form>
  111. </body>
  112. </html>
  113. <script language="JavaScript">
  114. <!--
  115. var SymRealOnLoad;
  116. var SymRealOnUnload;
  117.  
  118. function SymOnUnload()
  119. {
  120.   window.open = SymWinOpen;
  121.   if(SymRealOnUnload != null)
  122.      SymRealOnUnload();
  123. }
  124.  
  125. function SymOnLoad()
  126. {
  127.   if(SymRealOnLoad != null)
  128.      SymRealOnLoad();
  129.   window.open = SymRealWinOpen;
  130.   SymRealOnUnload = window.onunload;
  131.   window.onunload = SymOnUnload;
  132. }
  133.  
  134. SymRealOnLoad = window.onload;
  135. window.onload = SymOnLoad;
  136.  
  137. //-->
  138.  
[Please use CODE tags when posting source code. Thanks! --pbmods]

There are two buttons on the page- the submit button and the clear button. I want the clear button to redirect the person back to the previous page. I have tried unsing forms but my page loses its structure when I do that. Is there another way to to this

Thank you
Jun 3 '07 #1
Share this Question
Share on Google+
2 Replies


P: 93
Would this do it? (a bit of ye old javascript):

Expand|Select|Wrap|Line Numbers
  1. <input type="reset" name="clear" value="<<Undo" class="button" onclick="history.back();">
  2.  
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jun 3 '07 #2

100+
P: 103
If you really do want to send someone literally back to the previous page you could also just use an anchor tag with the href or just history.back() to use the javascript

[HTML]<a class="button" href="enterlink" onclick="history.back()">clear</a>[/HTML]

If you tweak the CSS you can get something approximating a button for your anchor tag.

Expand|Select|Wrap|Line Numbers
  1. .button {
  2.       font-family: verdana;
  3.       padding: 2px 10px 2px 10px;
  4.       background-color: #cccccc;
  5.       border: 1px solid #888888;
  6.       color: #444444;
  7.       text-align: center;
  8.       font-size: 0.8em;
  9.       text-decoration: none; 
  10.       cursor: pointer; 
  11. }
  12.  
Jun 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.