• 0

Form not submitted when click() method is used in Firefox.


Question

Hi!
 
I need to make an old made for IE only web app compatible with Chrome and Firefox. 90% of the job is done but i still have a small problem.
 
So i have a form like this.
 

<form id="formCarte" name="formCarte" method="post" action="{url}" enctype="application/x-www-form-urlencoded">    
  {inputs}
  <input id="formCarte:cmdCarte" name="formCarte:cmdCarte" type="submit" onclick="{someCode}" class="zoneCarteBoutonx" />
</form>

The code inside the onclick is generated by a framework (Apache MyFaces i think) so i have no control over this and it needs to be executed. The whole form is hidden and is submitted in javascript using the click method of the submit input. Basically there's a map (jpg image) and the user select a tool and then select a part of the map and then some javascript set the value of the inputs of the hidden form and then click() the submit input.
 

if({selectedTool} == {aTool})
{
  {setValueOfInputsBasedOnWhichPartOfTheMapWasSelected}
         
  // Soumettre au serveur
  getChampFrameCarte("cmdCarte").click();
}

My problem is the form is never submitted in Firefox. The javascript code of the onclick event of the submit input is executed but then the form is not submitted. I can't submit the form using the submit method of the form itself cause the framework doesn't execute the java code behind if i do so. If i display the form, set some values manually without using the map and tools and then click on the submit input myself then it works. The javascript code of the onclick event of the submit input is executed and the form is submitted.

Anyone had a problem like this before? If yes what did you do? Ideally i really need to submit this form using the click method of the submit input cause i don't want to mess with the framework since i don't know this framework at all let's just say i prefer to touch the javascript only.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Yes but i just found the solution so no reason to lol.

 

It's because the form is not displayed. When i change the form from display:none to display:block it works. I think i'll just position absolute the form and send it to left:-1000px lol ... ugly but hey that's an old ie only app they can't expect beautiful ;)

Link to comment
Share on other sites

  • 0

Yes but i just found the solution so no reason to lol.

 

It's because the form is not displayed. When i change the form from display:none to display:block it works. I think i'll just position absolute the form and send it to left:-1000px lol ... ugly but hey that's an old ie only app they can't expect beautiful ;)

You can also try using:

<input type="hidden" />

to hide form inputs.

 

Also if it's a hidden form you can just remove the submit button and use .submit() to submit the form.

Edit: saw that it's not possible to use .submit() in your case.

Link to comment
Share on other sites

This topic is now closed to further replies.