Jump to content

Form Action


jimfog

Recommended Posts

I am building a form where i want the user input be passed into a javascript file. So far, i have noticed(from my little experience in web development) that the user input is passed to files in the server-with the "form action" directive. Is the above necessary? Can the user input be passed to a javascript file where all the processing logic will reside? I do not want any server activity employed in this form. There will be a submit of course for the user to click and send the data. Thanks.

Link to comment
Share on other sites

Javascript can work with form data, but the form's data isn't sent to Javascript, it more like Javascript has to go pick up the information from the form. You use the submit event handler of the form to execute a Javascript function that works with the data. The data is not sent to a file, the Javascript that processes the data has to be on the page. Javascript is limited, though. Javascript cannot save information, write to files, or access pages from a different domain.

Link to comment
Share on other sites

So, you are saying that i cannot use a javascript file to process the data the way for example a php file does? It is simple processing, some if statements and math calculations. Can that be done with a js file containing all the relevant code?

Link to comment
Share on other sites

Yes, it's simple. Do you know Javascript?You need to know event handlers and HTML DOM. Make the Javascript run when the submit event of the form is fired. Use HTML DOM to access the form elements and retrieve their values.

Link to comment
Share on other sites

I know little javascript. Certainly, in comparison with an experienced developer it will take me more time to write the coderequired. 1 last q. I suppose, that since the data are passed to javascript file, the form action code will NOT be of the kind used when the data are passed to a php file for example: formaction="file,php" It will be kind of js event handling syntax. Correct?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...