views:

30

answers:

1

I'm writing a customer form, where a drop down menu should be automatically set to the appropriate option if the window.top.document.url is known.

To achieve this I do a <body onload='javascript:init([Generic value])' which calls

function init(value) {
     if (value) {
          document.getElementById('RefererURL').value = window.top.document.URL;
          form1.submit();
       }
   } 

I don't remember why we added the if(value) thing, but the rest is pretty straight forward - get the value, then submit the form to trigger an update that does the actual url-menu mappning.

This solution works in IE, but not in Firefox, and I can't figure out why. I'm suspecting it might have something to do with form1.submit();, but don't understand what or why.

+2  A: 

try

document.getElementById("form1").submit();

This assumes your form id is 'form1'.

Paul Whelan
My hero! :) Thanks.
Marcus L
Nice start to the day for me a hero ;)
Paul Whelan