Jump to content

[SOLVED] using <form> with <input type=image>


sirup_segar

Recommended Posts

hi,nice to be here again.i think i will often be here hehe ;)

i have a form like this


<form method='post' action='shop_action.php' name='frmshopaction'>
<table align='center' width='650' class='mytable'>
	<tr>
	 	--<tr declaration>--
	 </tr>
";

	for ($i=0;$i<$hitung;$i++)
	{
	$tmpisbn=$isbnx[$i];
	$tmpjdul=$judulx[$i];
	$tmppen=$penerbitx[$i];
	$tmppeng=$pengarangx[$i];
	$tmpqty=$qtyx[$i];
	$tmphrg=$hrgx[$i];
	$tmphrgtot=$hrg_qtyx[$i];
	$hrgrp=tampilrupiah($tmphrg);
	$hrgtot=tampilrupiah($tmphrgtot);
	$pricerp=tampilrupiah($price);
    	echo "<tr>
			 <td>$tmpisbn</td>
			 <td>$tmpjdul</td>
			 <td>$tmppen</td>
			 <td>$tmppeng</td>
			 <td>$hrgrp</td>
			 <td><input type='text' name='txt_qty[$i]' id='txt_qty[$i]' value='$tmpqty' size='1'></td>
			 <td>$hrgtot</td>
		 </tr>
  ";
}	

</table>";
echo "<table align='center'>
      <tr>
	  <td>
	  <input type='image' src='../image/lihat-katalog.gif' width='150' height='40' name='show'>
	   <input type='image' src='../image/update-qty.gif' height='40' width='150' name='edit'>
		<input type='image' src='../image/selesai-belanja.gif' width='150' height='40' name='chekout'></td>
	  </tr>
	   </table>
	  </form> 

and my shop_action.php is below

if (isset($_POST["edit"]))
{

--still working on Edit--
}
else if (isset($_POST["show"]))
{
      --still working on show too--
}
else if (isset($_POST["chekout"]))
{
	--also,still working on checkout--

 

when i clik one of my images on frmshopaction,none of my shop_action.php is done. anybody can give me an idea? thanks alot..

Link to comment
Share on other sites

if (isset($_POST["edit_x"])) and similarly for the other input images is what works. Clicking the image returns the coordinate values of the click relative to the image upper-left corner, i.e. $_POST[inputname_x'] and $_POST['inputname_y'].

Link to comment
Share on other sites

to andy, yes you're totally right.when i change my form method into 'get', in the address bar i saw weird parameter, like '

http://localhost/pim_update/pengunjung/shop_action.php?txt_qty%5B0%5D=70&txt_qty%5B1%5D=140&lihatkat.x=53&lihatkat.y=20

'

of course i'm confused about what's happen ;D .by the way, i have to change my input type=image's name into 'show_x' and 'show_y', 'edit_x' and 'edit_y', and also 'checkout_x' and 'checkout_y'? or replace the '_x' and 'show_y' with some number? because the value of '_x' and '_y' always changed. thanks a lot bro..

Link to comment
Share on other sites

for mr PFMaBiSmAd, sorry the answer is no,i didn't change back my form method to post. but i have now, and it worked.thanks a lot.  ;D for mr mmarif4u, thanks for the snippet..it's because i haven't change back the method into post.. ;D. by the way, how can i add the "topic solved" flag to my thread??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.