Re: <INPUT type="image"> problem with IE browser
by bart (Canon) on May 18, 2006 at 09:14 UTC
|
Looks like it. HTMLhelp.com doesn't mention a separate parameter for name=value, only name.x and name.y. Neither does the official HTML spec.
It looks like you'll have to find another way, like making your page number part of the name, such as
<INPUT type="image" name="page23" src="...">
A grep through all params with a name matching /^page(\d+)\.x$/ will then find your page number.
($param) = grep /^page\d+\.x$/, $cgi->param;
Or, using map, and the fact that a regex that doesn't match returns an empty list, and a list of captured matches if it does, that can even become:
($page) = map /^page(\d+)\.x$/, $cgi->param;
That doesn't look half bad to me. | [reply] [d/l] [select] |
Re: <INPUT type="image"> problem with IE browser
by davorg (Chancellor) on May 18, 2006 at 08:47 UTC
|
#!/home/crossda/perl/bin/perl
use strict;
use warnings;
use CGI ':cgi';
print header(-type => 'text/plain');
foreach (param) {
print "$_ : ", param($_), "\n";
}
You'll see that Firefox sends parameters called "page.x", "page.y" and "page". IE doesn't send the "page".
You'd need to check the specs, but I suspect that IE is doing all it's supposed to do. The extra parameter from Firefox is useful but (I think) non-standard.
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] [d/l] |
|
|
Even simpler (= less work), make the form use a GET (don't specify a method for the form) and look at the URL after you submit.
| [reply] |
Re: <INPUT type="image"> problem with IE browser
by McDarren (Abbot) on May 18, 2006 at 09:42 UTC
|
Actually, after seeing the rest of the replies I've realised that this is something that I had to deal with myself a while back.
The way I got around it was (as has been suggested) to assign individual names to each INPUT control. In my case, I was using arrow images as sorting buttons. The code to render the HTML was a little like so:
print qq(<input type="image" name="sort:$field:asc" src="$image_dir/do
+wn.png">);
The above was within a for loop, where the value of $field was changed on each iteration, to produce a unique name for each "button".
I had about 20 of these little "sorting" buttons on my page, so when it came to working out which one had been clicked (if any), I did this:
my ($sort_string) = grep { $_ =~ /^sort/ } @params;
my ($sort_field, $sort_dir)
= defined($sort_string)
? $sort_string =~ /^sort:(\w+):(\w+)/
: qw(avin desc);
The above worked fine in both IE and Firefox.
Hope this helps,
Darren :) | [reply] [d/l] [select] |
|
|
This one's very simple, yet clever approach. I'll implement this in my subsequent routine when necessary.
| [reply] |
|
|
| [reply] |
Re: <INPUT type="image"> problem with IE browser
by holli (Abbot) on May 18, 2006 at 09:04 UTC
|
It's a problem with IE. It simply does not send the values of the image buttons. I have a workaround for that, but it relies on Javascript:
<form action="/blabla" method="post">
<input type="hidden" name="mypage" id="mypage" value="" />
<input type="image" name="page" value="1" src="/static/images/suchen
+.gif" onclick="document.getElementById('mypage').value='1';" />
<input type="image" name="page" value="2" src="/static/images/suchen
+.gif" onclick="document.getElementById('mypage').value='2';" />
...
</form>
and later in the script:
$page = $cgi->param('page') || $cgi->param('mypage') || 1;
| [reply] [d/l] [select] |
|
|
It's a problem with IE
I think that's overstating the case. IE is doing exactly what it should be doing. Firefox has added some new and useful behaviour. But it's non-standard* and IE can't be expected to support it.
* Or, at least, I can't find any standards that mandate the Firefox behaviour.
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
|
|
| [reply] |
|
|
Thanks for your inputs guys! I made it to work using this workaround:
<TD>
<INPUT type="hidden" name="page">
</TD>
<TD>
<A href="javascript:do_Submit(1)"><IMG src="page1.gif" ...></A>
<A href="javascript:do_Submit(2)"><IMG src="page2.gif" ...></A>
<A href="javascript:do_Submit(3)"><IMG src="page3.gif" ...></A>
<A href="javascript:do_Submit(4)"><IMG src="page4.gif" ...></A>
...
<A href="javascript:do_Submit(50)"><IMG src="page50.gif" ...></A>
</TD>
The on the javascript:
function do_Submit(page) {
var page;
document.forms[0].page.value = page;
document.forms[0].submit();
}
I also confirmed that this wasn't supported in the HTML specs. I just assumed too much when I made the code. But I wasn't able to catch it soon enough since I am always using Firefox | [reply] [d/l] [select] |
Re: <INPUT type="image"> problem with IE browser
by ikegami (Patriarch) on May 18, 2006 at 14:56 UTC
|
<button name="page" type="submit" value="1"><img ...></button>
<button name="page" type="submit" value="2"><img ...></button>
<button name="page" type="submit" value="3"><img ...></button>
...
<button name="page" type="submit" value="50"><img ...></button>
| [reply] [d/l] |
|
|
Another bug in IE causes <button> elements to be submitted with the text content the element instead of the value attribute.
I could be wrong, but I seem to recall they IE also treats all <button>s as successful controls, even if they are unclicked submit buttons.
| [reply] [d/l] |
Re: <INPUT type="image"> problem with IE browser
by McDarren (Abbot) on May 18, 2006 at 08:41 UTC
|
Update: The below is absolute codswallop. Please see my slightly more sensible reply below
Try closing the INPUT tag, eg:
<INPUT type="image" name="page" value="1" />
--Darren | [reply] [d/l] |
|
|
| [reply] [d/l] |