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

Problem in images as a submit button

P: 23
Hi,
Here i have pasted 2 scripts first one is design and next one is country.php
in the below code is working nicely.
----------------------design.php------
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="country.hp">
  2. <table width="200" border="1" align="center">
  3.   <tr>
  4.     <td>contryname</td>
  5.     <td><input type="text" name="countryname"></td>
  6.   </tr>
  7. </table>
  8. <input type="submit" name="Submit" value="Submit">
-------------------country.php----------

Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post">
  2. <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  3.   <tr>
  4.     <div align="center">
  5.       <h1>List Of Events</h1>
  6.     </div>
  7.   </tr>
  8. <?php
  9.  include('connect.php');
  10. $str=$_GET['countryname'];
  11.  $sql="SELECT * FROM addevent where countryname LIKE'$str'";
  12.    // OREDER BY id DESC is order result by descending
  13.   $result=mysql_query($sql);
  14.   $num=mysql_num_rows($result);
  15.  while($rows1=mysql_fetch_array($result))
  16.     {
  17.      // Start looping table row
  18.       ?>
  19.  
  20.   <tr>
  21.  
  22.      <td width="6%" align="center" bgcolor="#E6E6E6"><strong>Event</strong></td>
  23.     <td width="23%" align="center" bgcolor="#E6E6E6"><strong>Date</strong></td>
  24.     <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Month</strong></td>
  25.     <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Year</strong></td>
  26.   </tr> 
  27.  
  28.  
  29. <?PHP
  30.      print "<tr bgcolor=\"#CCCCCC\">
  31.       <td bgcolor=\"#FFFFFF\">" . $rows1['event'] ."</td>
  32.       <td bgcolor=\"#FFFFFF\">" . $rows1['date'] ."</td>
  33.       <td bgcolor=\"#FFFFFF\">" . $rows1['month'] ."</td>
  34.       <td bgcolor=\"#FFFFFF\">" . $rows1['year'] ."</td>
  35.   </tr>";
  36.       // Exit looping and close connection
  37.          }
  38. if($num!=0)
  39. {
  40. echo"<B> Totaly $num found</B> ";
  41. }
  42. else
  43. {
  44.  
  45. echo"<center><B>No results found</B></center>"; 
  46. }
  47. mysql_close();
  48.  
  49.  
  50. ?>
  51. </table>
  52.  
  53. </form>

But i changes submit button into image and i dont want to give link in action field(if i give action its working) in this how can i redirect another one form using image as a submit button can anyone help me how to do this

thanks
Jul 21 '07 #1
Share this Question
Share on Google+
3 Replies


P: 93
You should be able to get an image or a link to submit a form by using onclick="document.formname.submit()" in the tag. You might be able to do [HTML]<a href="javascript:document.formname.submit()"><img src="example.jpg></a>[/HTML] And in your form tag you would need to have [HTML]<form name="formname">[/HTML]
Jul 21 '07 #2

ak1dnar
Expert 100+
P: 1,584
hey kavitha,
May be its better to try this way.
Its simple with a input elemenet type="image";

Expand|Select|Wrap|Line Numbers
  1. <form action="next.php" method="post" name="myform">
  2. <input name="myname" type="text" />
  3. <input name="myimgButton" type="image" src="images_dir_path/btn_image.jpeg" />
  4. </form>
  5.  
thanks!
-ajaxrand
Jul 21 '07 #3

pbmods
Expert 5K+
P: 5,821
Heya, Kavitha.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Jul 21 '07 #4

Post your reply

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