Jump to content

Recommended Posts

From my reading I believe that the onclick event that calls my js function happens before the button (submit) that triggered it actually triggers the php script designated in the form tag.  Here's my problem.

 

The JS function that is called by the onclick does some verification that may end up altering the value of a field in the form being submitted.  What I'm seeing is that the change to the field is NOT getting picked up by the POST in the php script triggered by the submit button.

 

Is that normal?  My debugging tells me that the modification to the field takes place in the js function, and I can even see the change on my screen.  But - when the script executes my echos tell me that the value didn't get picked up.  It seems that the POST vars are collected as soon as I click on the form's submit button, then the onclick JS function does its thing, and then finally the php script gets called, using the POST vars that had already been created.  Is this true?

Link to comment
https://forums.phpfreaks.com/topic/258665-onclick-and-submit-sequence/
Share on other sites

Not an Answer - but problem solved.

 

Since my js submit can't send the text of the submit button that triggered it and therefore my php script didn't know where the submit was coming from I did this.

 

Since the form that was involved had field names unique to that portion of my webpage, I just checked for the existence of one of those names and set the button field name=the text that is in the value= parm.  That allowed my script to think that it was coming from the appropriate form and my work can continue.

 

Interestingly enough - the problem wherein an html field that I modified in the JS function prior to the submit now shows up correctly in the PHP script, whereas when I was trying to let the submit button trigger the submit event after the onclick was complete, I was losing the value of that modified field.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.