Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
78
rated 0 times [  84] [ 6]  / answers: 1 / hits: 24973  / 13 Years ago, sun, february 26, 2012, 12:00:00

I am currently working on a php/html/javascript project. I have a form where when the user presses the submit button, it should run a javascript function and then afterwards post to a php page to process the data that was submitted in the form.



I have the form run a javascript method as below



<form class=form id=addImageForm name=addImageForm action=javascript:validateAddImage(); method=post>


The method validates the form, calls another method and then it submits the form using document.myForm.submit();



How do I get it to submit the form to another php page to process the data including upload selected files.



Thanks for any help you can provide.


More From » php

 Answers
12

Set yout 'action' parameter to your PHP script, and do any javascript procesing in a javascript event.



<form class=form id=addImageForm name=addImageForm action=processing.php method=post onsubmit=return validateAddImage();>


Then in your js validation, return 'true' if everything's fine, or 'false' if not. Returning 'true' means 'continue with the submit process and send over data to processing.php


[#87203] Friday, February 24, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josefn

Total Points: 251
Total Questions: 93
Total Answers: 84

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;