Hello, I have the following form on my site: <script type="text/javascript"> /* <![CDATA[ */ function sub() { window.location.href = site; } function goTo(URL) { site = URL; } /* ]]> */ </script> <form name="frmSite"> <div class="row clearfix"><input class="ccheckbox" type="radio" name="site" onchange="if(this.checked){goTo('http://www.google.com')}" />Créer une entreprise</div> <div class="row clearfix"><input class="ccheckbox" type="radio" name="site" onchange="if(this.checked){goTo('http://www.google.com')}" />Acquérir une entreprise existante</div> <div class="row clearfix"><input class="ccheckbox" type="radio" name="site"onchange="if(this.checked){goTo('http://www.google.com')}" /> Devenir associé dans une entreprise</div> <div class="row clearfix"><input type="image" alt="Soumettre" id="ssubmit" src="http://www.test.com/commentcer.png" value="Submit" onclick="sub()" /></div> </form> ----------- When I use a Submit button, instead of a Submit image, I am able to send the visitor to a different page based on his selection. However, when I use an image, such as in this case, the redirect does not work and instead I have something like this loading:http://www.url.com/?site=on&x=73&y=21...where I guess X and Y are coordinates or something...i have no idea where they come from.. Do you by any chance know what I should change to make this form work with an image submit instead of a button submit? I suspect its in the Javascript..?
At quick glance (untested)... the "site" variable is exclusive to the goTo() function and cannot be accessed from the sub() function. If you would like to use the "site" variable in multiple functions declare the variable outside of the function. Like so: var site; function blah1() {} function blah2() {} But looking over your code you don't have a use for sub() at all. And btw I wouldn't name your functions goto() and sub(). It looks confusing since those can be private functions in standard programming languages. You could use the following: function redirectTo(URL) { window.location.href = URL; }