Welcome to WebmasterWorld Guest from 54.166.54.215

Forum Moderators: incrediBILL

Onchange event not working on Firefox?

   
12:09 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



I'm having some problems on Firefox when using the onchange event.
Basically the onchange calls 2 javascript functions and it works fine on IE but not on FF.
The website address is <SNIP>
Any help or suggestions would be appreciated.

[edited by: BlobFisk at 12:48 pm (utc) on Jan. 17, 2005]
[edit reason] No URLs please! See TOS [webmasterworld.com] [/edit]

12:50 pm on Jan 17, 2005 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, Nazgoth!

Could you post the code for the onchange event? Maybe it is a problem in the script that is causing the problem...

2:18 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



The code for the combobox is as follows:

<?php
echo('<td colspan="2" align="right"><select name="select" class="combobox" onchange="disable_location(); submit_value(select.value,'.$HTTP_GET_VARS["lid"].');">'.$prop_types.'</select></td>')
?>

But the 2 javascript functions - disable_location() and submit_value() - are not being executed, which I think is because the onchange event not being triggered.

2:47 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



Here's the javascript functions as well in case the problem is there.

function disable_location()
{
select2.disabled=true;
}

function submit_value(pid,lid)
{
var caminho=window.location.href;
window.location="index.php?pid="+pid+"&lid="+lid+"&prid=0&pag=1";
}

2:48 pm on Jan 17, 2005 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Have you tried escaping the characters in the script here:

<?php
echo('<td colspan="2" align="right"><select name="select" class="combobox" onchange="disable_location(); submit_value(select.value,'.$HTTP_GET_VARS["lid"].');">'.$prop_types.'</select></td>')
?>

I think the php quotes and JS quotes need to be escaped (especially the double quoteS)....

2:58 pm on Jan 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, the quotes look ok, except for one set. Since you surrounded youe echo string with singles, you should use singles in the $HTTP_GET_VARS array. Also, I believe you need a semicolon at the end of the echo. I could be wrong, since it's a one liner but just looking for probs.

<?php
error_reporting(E_ALL); // Crank up error reporting temporarily
echo('<td colspan="2" align="right"><select name="select" class="combobox" onchange="disable_location(); submit_value(select.value,'.$HTTP_GET_VARS['lid'].');">'.$prop_types.'</select></td>');
?>

Also, is the actual HTML output from the script what you intended it to be?

Blobfisk, the single quotes are being used for PHP concenation, rather than for enclosing a JS var. I'm assuming that var is a number, or else it will need another set of singles. And they would need escaping as you said above.

[edited by: Birdman at 3:04 pm (utc) on Jan. 17, 2005]

3:01 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



I managed to fix the problem, in case anyone else is having the same problem... Apparently FF does not define name="select" but with id="select" it works fine...
Oh well, was only a couple of wasted hours trying to fix it lol
5:06 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



Where you have "select.value" you should actually be using:

options[selectedIndex].value
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month