www.webdeveloper.com
Results 1 to 2 of 2

Thread: problem when submitting a form in javascript

  1. #1
    Join Date
    Nov 2006
    Posts
    22

    problem when submitting a form in javascript

    Hi there. ive got a problem when submitting a form via form.submit() method. The page is like this:

    i've got a form where the users submits data. Aside, there's a link leading to another page. Where the users presses the submit button there's no problem. The problem is where the user press the link to the other page. If there are data in the input boxes i submit the form via document.form.submit(); method and then the page automagically goes to the other page. However there's a problem: the data are not saved but if a put a alert() just following the document.form.submit(); the data IS saved so i assume that there's no time between the form.submit() and the <a href> element leading to the other page.

    The steps i follow when the user presses the link are:
    -check if there are data in the input. i use the onkeyup="savechange();" event in every input element and do change = 1 in the function.
    -if there are data (change==1) i call document.form.submit();
    -then the page redirects automatically to the linked page.

    But the data are not saved. However if a put a alert(); call following the submit() form method the data are saved. I need some help to solve this, please.
    Thanks

  2. #2
    Join Date
    Nov 2006
    Posts
    197
    Are you trying to retrieve the posted form data via JavaScript on the other page? If so... document.formName.submit() will do the POST submission but client side JavaScript can not process such a FORM submission as it has no acess to the POSTed data.

    The alert() you mention is most likely reading what is in the form fields, not what gets POSTed.

    If I am off base, show your code for evaluation.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles