Javascript document.forms[0].submit() not submitting form values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KOFI QUANSAH
    New Member
    • Oct 2006
    • 2

    Javascript document.forms[0].submit() not submitting form values

    Hello,
    1) I have a php script A with several buttons(not submit) on a form.
    2) On click of any of the buttons, a specific javascript function is called.
    3) Depending on the outcome of the javascript function, a second php script, (set in the action property of the form) B is called with the document.forms[0].submit() function.

    Problem: Javascript correctly references script B. However, I cannot reference any of the $_POST values. They are practically empty.

    If however, I make the buttons submit buttons, everything works out just fine. But I need to use the javascript approach, because even though all the buttons reference the same script B, they do so under entirely different conditions.

    Thank you.
  • Amzul
    New Member
    • Oct 2007
    • 130

    #2
    try give the form id and then document.getEle mentById('formi d').submit() it
    and put some code here your problem is not that clear to me

    Comment

    • Nert
      New Member
      • Nov 2006
      • 64

      #3
      Maybe the browser you are using does not support document.forms[0].submit()

      try changing it to document.formNa me.submit()

      Comment

      • KOFI QUANSAH
        New Member
        • Oct 2006
        • 2

        #4
        Hi, the problem is fixed. But this is how I sorted myself out.
        I made all my buttons submit buttons. However, for each button, the onclick event is set to a specific boolean javascript function.

        Hence, when the javascript function returns true, onlclick=true and the form is submitted.Other wise, no submission.

        Comment

        Working...