PDA

View Full Version : Image buttons and Opera/IE issue


Badman3k
11-04-2005, 03:22 PM
I've been using a form which lists a load of items which can be checked. I want to be able to check multiple items and then click one of two inputs (with type = image) to submit the form with the items checked.

For some reason Opera and IE don't seem to work. They just appear to refresh the page, without any submission. FF on the other hand, takes the info and processes it.

The page is created dynamically, but this is the html that's printed. If anyone can shed some light on it, I’d be very grateful:

<form method="post" action="index.php" name="events">
<input type="hidden" name="sCat" value="administration" />
<input type="hidden" name="sAction" value="events" />
<table width="100%" cellspacing="0" class="border">
<tr>
<th width="1%"><input type="checkbox" name="checkAll" value="all" onClick="negateChoice(events)"></th>
<th class="left">Titel</th>
<!--<th class="left">Beschreibung</th>-->
<th>Ort</th>
<th>Datum</th>
<th>Zeit</th>
<th>Ver&ouml;ffentlicht</th>
<th>&nbsp;</th>
</tr><tr class="white">
<td class="center"><input type="checkbox" name="iEventsId[]" value=""></td>
<td><a href="index.php?sCat=administration&amp;sAction=events&amp;sSub=details&amp;iId=">Test Title</a></td>
<td class="center">The Crags</td>
<td class="center">TBA</td>
<td class="center">18:50</td>
<td class="center"><img src="../templates/admin/img/tick.png" alt="tick" /></td>
<td>&nbsp;</td>
</tr><tr class="white">
<td class="center"><input type="checkbox" name="iEventsId[]" value=""></td>
<td><a href="index.php?sCat=administration&amp;sAction=events&amp;sSub=details&amp;iId=">To add or not to add</a></td>
<td class="center">That is the question....</td>
<td class="center">01.01.2007</td>
<td class="center">TBA</td>
<td class="center"><img src="../templates/admin/img/cross.png" alt="cross" /></td>
<td>&nbsp;</td>
</tr>
</table>
<img src="../templates/admin/img/arrow_selected.gif" /> <span class="italic">ausgew&auml;hlte:</span> <input type="image" src="../templates/admin/img/file_delete.gif" name="sSub" value="del" /> <input type="image" src="../templates/admin/img/file_edit.gif" name="sSub" value="edit" />
</form>

Many thanks in advance,

Badman3k
11-04-2005, 10:35 PM
Okay after a bit of testing and some searching I eventually found the solution. So here it is:

SOLUTION:
For an input with type=image, the value attribute is not meant to be sent to the server on submit. The only thing that gets passed to the server is the xy coordinates of where on the image the user pressed.

Therefore I needed to change the name of the input to the value (add the alt text to support accessibility), and then in the PHP code I was using do a test for isset(name_x) or isset(name_y) and this would then i could easily hard code the rest.

I hope this helps someone else in the future.