Click to See Complete Forum and Search --> : mozilla getElementById()


dave_weldon
09-09-2004, 07:00 AM
Hi guys,

Im a little stumped as to why the following code doesnt work in firefox. It works fine in IE... all help will be much appreciated!!!


function go(optn) {
document.getElementById("g").value = optn;
document.form1.submit();
}

Im not a javascript person btw!

cheers,

Dave.

Kor
09-09-2004, 07:21 AM
check wether your firefix is javascript enabled

dave_weldon
09-09-2004, 07:59 AM
it is... it log's the error in the javascript console. The error is to do with undefined parameters if thats and help. And its on the line with getElementById in it.

Malas
09-09-2004, 08:55 AM
a siimple solution would be to just use.

document.form1.g.value = optn;


To fix the code you currently have, would need to see the html for the form. Would guess that it is a name/id problem.

dave_weldon
09-09-2004, 09:26 AM
here is a link to one of the page, thanks very much for all your help!

***

dave_weldon
09-09-2004, 09:42 AM
erm... seems to all be working. must have been this line that fixed it:


document.form1.g.value = optn;

and my browser may have cached the file with all the javascript funtions in it.. all i can think of! meh! im not bothered as long as it works!

Cheers :D

Malas
09-09-2004, 10:08 AM
general rule of thumb I have gotten into the habit of doing is to hold shift whenever I hit refresh. It is supposed to force the browser to reload all files. Sometimes it fails depending on how your cache settings are done, but if you set your caching to ever visit to the page and hold shift, it will reload all elements everytime.

mrmoo
01-16-2006, 08:42 AM
I've had similar problem with drop downs in FireFox,

<script type="text/javascript">
function go()
{
s = "product-images/"
p = document.getElementById("select2").value
q = ".jpg"
imag.src = "/product-images/"+p+q
}


do I need to add the form name after "document"?