You are here: Re: submit button works but not image IE/Firefox « All PHP « IT news, forums, messages
Re: submit button works but not image IE/Firefox

Posted by Rik on 08/09/06 13:19

Matt wrote:
> "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
> news:c41e4$44d9cff4$8259c69c$5908@news2.tudelft.nl...
>> Matt wrote:
>>> "Markus Ernst" <derernst@NO#SP#AMgmx.ch> wrote in message
>>> news:44d9a244$1_2@news.cybercity.ch...
>>>> Matt schrieb:
>>>>> I have an issue when trying to use an image type Submit for a
>>>>> search.
>>>>>
>>>>> The code below works fine in Firefox 1.5.0.6 but not in IE7 Beta 3
>>>>>
>>>>> <form method="post" action="<?php echo $PHP_SELF?>">
>>>>> Search Edinburgh
>>>>>
>>>>> <!--<input type="Submit" name="search" value="Search">-->
>>>>> "Search" button commented out, works in both IE7 Beta 3 and
>>>>> Firefox
>>>>> 1.5.0.6
>>>>>
>>>>> <input type="Text" name="srchtxt" value="Enter Search Text">
>>>>>
>>>>> <input type="image" src="images/search.gif" name="search">
>>>>> "Search" image works in Firefox 1.5.0.6 but not IE7 Beta 3
>>>>>
>>>>> </form>
>>>>>
>>>>> <?php
>>>>> if ($_POST['search']) {
>>>>>
>>>>> $srchtxt=$_POST["srchtxt"];
>>>>> echo "Results for \"$srchtxt\"<br /><br />";
>>>>> include ("../../include/search.php");
>>>>> } else {
>>>>> include ("../../include/show.php");
>>>>> }
>>>>>>
>>>>
>>>> You should not check for the submit button anyway, as a form can be
>>>> submitted by hitting the enter key. Check for the searchtext
>>>> instead:
>>>>
>>>> if (isset($_POST['srchtxt']))
>>>
>>> Thanks to all, I've gone with the above method and all is working
>>> fine.
>>
>> For future reference:
>> When using an image as submit button, the coordinates are sent. So,
>> search.x
>> and search.y is posted. Because dots aren't allowed in variablenames
>> PHP converts this to search_x & search_y.
>>
>> print_r($_POST) and you'll see.
>
> Thanks Rick
>
> Ninja mentioned something along the same lines, though not having
> heard of this before I went for - to me - the easiest solution. I'm
> intrigued now, is the idea that you can have different actions
> dependant on where an image is clicked?

Yes, there's loads of possibilities to alter the action depending on WHERE
the user clicked exactly. It's not widely used, and for good reason: it will
require the click of a mouse, which is something a lot of user-agents won't
do (think of a screen reader, a lot of cellphones, etc.), and it requires
the displaying of an image, which is a dangerous assumption to begin with.

Oh, and it's Rik without a 'c' :-).

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация