Connecting Tech Pros Worldwide Help | Site Map

is it possible with in one form more than 1 submit buttons

Member
 
Join Date: Aug 2007
Posts: 120
#1: Oct 16 '07
Hi everybody,

Hi iam strugling with more than one submit buttons with in one form
here is my code

Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="Offer.php" name='issueFrm' onSubmit="return fullOfferfields();">
  2. OFFER <input type=image src="amarok_rewind.png " title="rewind" > <input type=image src="amarok_back.png" title="back"> <input type="text" size=3 name='txt'>&nbsp;<input type=image src="amarok_next.png " title="next" >&nbsp;<input type=image name='frwd' src=
  3. "amarok_fastforward.png" title="fastforward" value='submit' alt='fastforward'>
  4. <input type=submit name=ss value=Submit>
  5. </form>
  6.  
  7. once i clicked on image submit button it has to post some data.
  8. this one working on Mozilla browser what is the problem could you explain me
  9. and here is my entire code 
  10.  
  11.  
  12. code:
  13. <html>
  14. <body>
  15. <table>
  16. <tr height=1>
  17.    <td  width=100% align=center class="pageheader" background="sidebar.gif" colspan=8 cellpadding=0 cellspacing=0>
  18. <form method="post" action="Offer.php" name='issueFrm' onSubmit="return fullOfferfields();">
  19. OFFER &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
  20. ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  21. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  22. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  23. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  24. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  25. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  26. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  27. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  28. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  29. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=image src="amarok_rewind.png " title="rewind" > <input type=image src="amarok_back.png" title="back"> <input type="text" size=3 name='txt'>&nbsp;<input type=image src="amarok_next.png " title="next" >&nbsp;<input type=image name='frwd' src=
  30. "amarok_fastforward.png" title="fastforward" value='Submit' alt='fastforward'>
  31. </td>
  32. </tr>
  33. </hr>
  34. <?php
  35. #$cxn = mysql_connect("localhost","root","mysql");
  36. #$db = mysql_select_db("phoenixhrdb",$cxn);
  37. include_once("functions.php");
  38. $cxn = connect_to_db("vars.php");
  39. #echo $cxn;
  40. echo $_POST['frwd'];
  41. if(isset($_POST['frwd']) or !empty($_POST['frwd'])){
  42. $query="select Max(ID) as id from Offer";
  43. echo $query;
  44. $result=mysql_query($query,$cxn);
  45. $row=mysql_fetch_array($result);
  46. $id=$row['id'];
  47. #echo $id;
  48. $all_query="select * from Offer where ID='$id'";
  49. $all_result=mysql_query($all_query,$cxn);
  50. $all_row=mysql_fetch_array($all_result);
  51. $all_id=$all_row['Position_Name'];
  52. #echo $all_id;
  53. $all_client=$all_row['Client'];
  54. #echo $all_client;
  55. $all_candidate=$all_row['Candidate'];
  56. #echo $all_candidate;
  57. $all_desig=$all_row['Designation'];
  58. #echo $all_desig;
  59. $all_expdate=$all_row['Company_Exp_Doj'];
  60. $all_offer=$all_row['Offer_date'];
  61. #echo $all_offer;
  62. $all_offerctc=$all_row['offer_CTC'];
  63. #echo $all_offerctc;
  64. $all_status=$all_row['Status'];
  65. #echo $all_status;
  66.  
  67. }
  68. ?>
  69. <tr>
  70. <td colspan=7 width=100% height=100%>
  71. <table border=0 width=100% height=100%>
  72. <tr width=100% height=100%>
  73. <td colspan=7 width=80% height=100%>
  74. <table border=0 width=100% height=100%>
  75. <tr width=100% height=100%>
  76. <td width=25% height=100% valign=top>
  77. <SCRIPT language=JavaScript id=jscal1xx>
  78. var cal1xx = new CalendarPopup("testdiv1");
  79. cal1xx.showNavigationDropdowns();
  80. </SCRIPT>
  81.  
  82. <table width=95% align=center cellpadding=4 cellspacing=0 border=0>
  83. <tr><td></td></tr>
  84. <tr><td colspan=8 class="field" background="sidebar.gif"><u>Offer Details</u></td></tr>
  85.   <tr><td></td></tr>
  86. <tr><td class="field">Client Name <font color="red">*</font></td><td><select id='department'  name="CCode" onChange='load()' >
  87. <?php
  88.  
  89. #$cxn = mysql_connect("localhost","root","mysql");
  90.  
  91. #$db = mysql_select_db("phoenixhrdb",$cxn);
  92.  
  93. $CName_query = "select Client_Name from Client";
  94.  
  95. $CName_result = mysql_query($CName_query) or die("Could not connect to database".mysql_error($cxn));
  96.  
  97. while($Crow = mysql_fetch_array($CName_result)){
  98. $clientname[] = $Crow['Client_Name'];
  99.  
  100.  
  101.  }
  102. for($i=0; $i< sizeof($clientname); $i++)
  103.  
  104. {
  105.  
  106.         echo "<option value='$clientname[$i]'";
  107.  
  108.         if($clientname[$i] == @$_POST['CCode']){
  109.  
  110.                 echo "selected";
  111.  
  112.         }
  113.  
  114.         echo "> $clientname[$i]</option>";
  115.  
  116.  }
  117.  
  118.  
  119.  
  120. ?>
  121.  
  122.  
  123. </select>
  124.  
  125.   </td></tr>
  126.  
  127. <tr><td class="field">Position Name <font color="red">*</font></td>
  128.  
  129. <td>
  130.  
  131. <?php
  132.  
  133. echo ("<select  id='faculty', name='PCode' selected >");
  134. $n=$_POST{'PCode'};
  135. echo "<option value='$n'>";
  136.  
  137.         #             echo "selected";
  138.  
  139.  
  140.         echo " $n</option>";
  141.  
  142. echo ("</select>");
  143.  
  144. #iecho $n;
  145. ?>
  146.  
  147. </td></tr>
  148.  
  149. <tr><td class="field">Candidate Name <font color="red">*</font></td><td>
  150. <?php
  151.   $candquery = "select distinct Candidate_Name from Interview where  I_status='Confirmed' ;";
  152. $candresult = mysql_query($candquery,$cxn);
  153.   while($candrow = mysql_fetch_array($candresult)) {
  154.     $candname[] = $candrow['Candidate_Name'];
  155.   }
  156. ?>
  157. <select  name="canname" >
  158. <?php
  159. if(isset($_POST['frwd'])){
  160. echo"<option value='<?php echo $all_candidate;' ?>$all_candidate</option>";}
  161. $i=0;
  162. while($i<sizeof($candname)) {
  163.  
  164.         if($all_candidate==$candname[$i]){$i++;}
  165.       echo ("<option value='$candname[$i]'>$candname[$i]</option>");
  166. $i++;
  167.     }
  168. ?>
  169. </select>
  170. </td>
  171. </tr>
  172.  
  173. <tr><td class="field" >Designation </td><td>
  174.  
  175.  
  176.  <select  name="designation" >
  177. <?php
  178. include("designation.inc");
  179. ?>
  180. </td></tr>
  181. <?php
  182. if(isset($_POST['frwd'])){
  183. echo "<tr><td class='field'>Expected date of joining </td><td><input type='text' name='exdoj' size='7' readonly title='Select Date' value='$all_expdate'>";
  184. }
  185. else{
  186. echo "<tr><td class='field'>Expected date of joining </td><td><input type='text' name='exdoj' size='7' readonly title='Select Date'>";}
  187. ?>
  188. <a id=anchor2xx  onclick="cal1xx.select(document.forms[0].exdoj,'anchor2xx','dd/MM/yyyy'); return false;"
  189. href="http://www.mattkruse.com/javascript/calendarpopup/index.html#"
  190.  
  191. name=anchor2xx><img src="cal.gif"></img></a>
  192. </td></tr>
  193. <?php
  194. if(isset($_POST['frwd'])){
  195. echo "<tr><td class='field'>Offer date </td><td><input type='text' name='ofd' size='7' readonly title='Select Date' value='$all_offer'>";
  196. }
  197. else{
  198. echo "<tr><td class='field'>Offer date </td><td><input type='text' name='ofd' size='7' readonly title='Select Date'>";}
  199. ?>
  200. <a id=anchor1xx
  201.  title="cal1xx.select(document.forms[0].ofd,'anchor1xx','dd/MM/yyyy'); return false;"
  202.  onclick="cal1xx.select(document.forms[0].ofd,'anchor1xx','dd/MM/yyyy'); return false;"
  203. href="http://www.mattkruse.com/javascript/calendarpopup/index.html#"
  204.  
  205. name=anchor1xx><img src="cal.gif"></img></a> </td></tr>
  206. <tr><td colspan='2' align='right'></td></tr>
  207. <tr><td class="field">Offer CTC </td><td><select name="offctc" >
  208.  
  209. <?php
  210.   $i=0;
  211. if(isset($_POST['frwd'])){
  212. echo("<option value='$all_offerctc' selected>$all_offerctc</option>");}
  213.  
  214. while($i<=50){
  215.  
  216. #if(isset($_POST['frwd'])){
  217. #echo("<option value='$all_offerctc' selected>$all_offerctc</option>");}
  218. if($all_offerctc==$i){$i++;}
  219.   if($i==0) {
  220.  
  221.       echo ("<option value='$i'>Select</option>");
  222.   }
  223.   else {
  224. #for($i=0; $i<=sizeof($exp_salary); $i++) {
  225.  
  226.   echo ("<option value='$i'>$i</option>");
  227.  
  228. # }
  229.   }
  230. $i=$i+0.5;
  231.  }
  232.  
  233. ?>
  234. </select>
  235.  
  236. </td></tr>
  237. <tr><td class="field">Status </td>
  238. <td><select name="st">
  239. <?php
  240. if(isset($_POST['frwd'])){
  241. echo"<option value='$all_status' selected>$all_status</option>";
  242. }
  243. $a=0;
  244. $arr=array("Accepted","Rejected","Joined");
  245. while($a<sizeof($arr)){
  246. if($all_status==$arr[$a]){$a++;}
  247. echo"<option value='$arr[$a]'>$arr[$a]</option>";
  248. $a++;
  249. }
  250. ?>
  251. </select>
  252. </td></tr>
  253.  
  254. <tr><td></td></tr>
  255. <tr><td colspan=3 align=center><input type="submit" name="offersubmit" value="Submit"></td></tr>
  256.  
  257. </table>
  258. </form>
  259.  
  260. <tr height=15><td  align=center background="sidebar.gif" colspan=8 cellpadding=0 cellspacing=0 class=footertxt>copyright2007 @ phoenixhrsolutions</td></tr>
  261. </table>
  262.  
  263. </body>
  264. </html>
  265.  
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Oct 16 '07

re: is it possible with in one form more than 1 submit buttons


Next time enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

moderator
Newbie
 
Join Date: Oct 2007
Location: MN
Posts: 6
#3: Oct 16 '07

re: is it possible with in one form more than 1 submit buttons


In your code you are using isset['frwrd'] to check if the image button was clicked. When you are using that type of button, the post value, at least in Firefox, is not called frwrd. There are two post values frwrd_x and frwrd_y which indicate the location on the image where the user clicked. You could change your input type to a submit button and style it's appearance if you'd like to avoid rewriting some of your PHP code.
Reply