views:

204

answers:

4

Hello, I'm using the document.form.submit() function for a rather large input form (hundreds of fields, it's an inventory application). I'm calling this after the user has been idle for a certain amount of time and I would like to save any data they've typed. When I try this the page reloads (the action is #) but any new text typed in the fields is not passed in the REQUEST, so I don't get to put it in the DB. Is there some fundamental reason why this happens or is my code just not playing nice together (I'm using the EXTJS grid view to show the form and a library for tracking idle time)? Thanks, Robert

A: 

Might the server be voiding out the input values. Say if your page on the server looks like this:

<form action="/page.cgi">
  ...
  <input name="Fieldx" value=""/>
</form>

I think it'll void out the field. Or this the server action might be setting it indirectly. In JSF, something like this.

<input name="Fieldx" value="#{bean.nullProperty}"/>

What do you have on the server and what's your browser?

sblundy
A: 

I would try to catch the HTML post request to see if the input fields are included. If they are then your server has problem.

But regarding what you said, I think it's because there's conflict in the way your browser handles JavaScript DOM. This may be the case if you leave out the submit button on your form and it works.

Martin
+1  A: 

I guess I put the answer here. What I found was that doing this: setTimeout('frm.submit();', 2000); caused the page to reload but didn't submit the form. When I did this: frm.submit(); The form was submitted and the data was passed. I don't know why the first way didn't work, but I don't need to know that:)

Robert
Thanks for the answers, I didn't see them before posting my result though.
Robert
I also found out later that the reason the first way didn't work is because of the single quotes around the function within setTimeout. I got it to work using the setTimeout function once I put double qoutes around frm.submit();.
Robert
A: 

The submit method of HTMLFormElement objects should just submit the form, as if the user had clicked the submit button. So, if the action attribute of the form is set to #, it would just seem to refresh the page, because it’s sending the form data to the same page.

Strange that it still does it when you set the action attribute to another page though.

Is the method attribute of the form set to get or post?

Paul D. Waite
The method is POST.
Robert