Current location: Hot Scripts Forums » Programming Languages » PHP » image submit button problems


image submit button problems

Reply
  #1 (permalink)  
Old 06-13-03, 06:19 AM
Pepe Pepe is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Spain
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question image submit button problems

Hello php coders,

I am creating a form that uses images instead of buttons to submit information and I found some problems: type=image does not pass the value.

I am creating this system to delete lines from a shopping cart, therefore every "delete" button has a different value but I am not able to get it once the form is processed.

Exmaple:

<table>
<form name="formulario" action="pruebas.php" method="post">
<tr>
<td>
<input name="delete" type="IMAGE" value="7" src="a.gif" width="70" height="26" border="0">
</td>
</tr>
</form>
</table>

once this form is submitted I echo $delete and nothing appears on the screen, I could use $delete_x and get the some screen coordinates.

I got a workaraound but it looks a little complex:

I inserted the value of the button inside the name tag like

name="delete_id"

while (list ($clave, $val) = each ($HTTP_POST_VARS)) {
if (ereg("x", $clave) > 0){
$clave2_array = explode("_", $clave);
$clave2 = $clave2_array[1];
echo "The value is" . $clave2 . " and the button is" . $clave2_array[0];;
} // if
} //while


this way I get the value passed.

This problem only happens on IE, Mozilla treats the type=image as a type=submit.

Did you find any other solution to this?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-13-03, 06:28 AM
Stefan's Avatar
Stefan Stefan is offline
Junior Code Guru
 
Join Date: Jun 2003
Location: Utrecht, The Netherlands
Posts: 599
Thanks: 0
Thanked 0 Times in 0 Posts
what about using a hidden input with the id as value.... and just never look at the button
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-13-03, 06:34 AM
Pepe Pepe is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Spain
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
this way... which of the delete buttons in associated to which hidden input? say you have three items in your shopping cart and want to delete id_cart="7".... hope you understand this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-13-03, 06:37 AM
Pepe Pepe is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Spain
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Take a look at what Amazon is doing:

<input type=image name="submit.delete-id.U168FU" value="Delete" border=0 alt="Delete" src=http://g-images.amazon.com/images/G/01/detail/delete-sm-01.gif width=44 height=14 >
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-13-03, 06:45 AM
The Wolf's Avatar
The Wolf The Wolf is offline
CMS Developer
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
You could have a hidden input with the value of the row to be deleted, and when the user clicks on the 'delete' button it uses 'onMouseDown' to set the hidden inputs value then submits the form.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-13-03, 06:48 AM
Pepe Pepe is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Spain
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
this means javascript is enabled on the browser, I want my shopping cart JS FREE.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 06-13-03, 06:57 AM
The Wolf's Avatar
The Wolf The Wolf is offline
CMS Developer
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
You could also have seperate forms for each item and have the action something like './delete.php?id=2'.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 06-13-03, 07:03 AM
Pepe Pepe is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Spain
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
good idea, I will go on with this option.

Thank you all.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 06-13-03, 07:09 AM
The Wolf's Avatar
The Wolf The Wolf is offline
CMS Developer
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Glad to solve another prob, and be one more post towards the ability to add my own avatar...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 06-13-03, 08:20 AM
Stefan's Avatar
Stefan Stefan is offline
Junior Code Guru
 
Join Date: Jun 2003
Location: Utrecht, The Netherlands
Posts: 599
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally posted by The Wolf
You could also have seperate forms for each item and have the action something like './delete.php?id=2'.
this was actually what I had in mind while writing my post, though I was thinking of a seperate form per item. this solution though, is much more efficient in html coding. less forms == good
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic image src = Newbie question clintre PHP 1 10-07-03 10:56 AM
radio button selection TheLaughingBandit ASP 3 08-31-03 07:22 PM
camera phone image poster apt2 Script Requests 2 08-29-03 08:20 PM
A different kind of image counter Stix Script Requests 1 08-12-03 12:50 AM
Skript to convert email to image spade PHP 1 06-11-03 10:28 AM


All times are GMT -5. The time now is 06:48 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.