Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How can I set the form action through JavaScript?

//Set your form action
document.getElementById('myFormId').action="./myPage.myLanguage"

//display on console your form action
connsole.log(document.getElementById('myFormId').action)

//retrive the action from a selected Form
document.getElementById('myFormId').action
Comment

form action in html

<!--Answer from W3 Schools-->
<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" required>
  <input type="submit">
</form>
Comment

html form action javascript method

A form action set to a JavaScript function is not widely supported, I'm surprised it works in FireFox.

The best is to just set form action to your PHP script; if you need to do anything before submission you can just add to onsubmit

Edit turned out you didn't need any extra function, just a small change here:

function validateFormOnSubmit(theForm) {
    var reason = "";
    reason += validateName(theForm.name);
    reason += validatePhone(theForm.phone);
    reason += validateEmail(theForm.emaile);

    if (reason != "") {
        alert("Some fields need correction:
" + reason);
    } else {
        simpleCart.checkout();
    }
    return false;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: (this).find 
Javascript :: usestate in react 
Javascript :: .has js 
Javascript :: Query MongoDB - Node.js 
Javascript :: js access array value if exist 
Javascript :: add new element to existing json object 
Javascript :: arrow function in javascript 
Javascript :: objects in javascript 
Javascript :: passport local 
Javascript :: rxjs operators 
Javascript :: callback in javascript 
Javascript :: counting pairs in an array, resulting in a given sum 
Javascript :: js if statement 
Javascript :: pure component in react 
Javascript :: last element from list javascript 
Javascript :: Material-ui Account Balance icon 
Javascript :: axar patel ipl team 
Javascript :: jmathplot 
Javascript :: how to display ä in js 
Javascript :: dart get vfirst key value of map 
Javascript :: how to print array of 52/ print it 5 times with different value in javascript 
Javascript :: file_get_contents api json 
Javascript :: how to acces db knex 
Javascript :: contries code react native 
Javascript :: node alternative to btoa 
Javascript :: feathersjs mysql example 
Javascript :: eosio name to int js 
Javascript :: discord.js bot credits command 
Javascript :: processing map in javascript 
Javascript :: get only one type from json 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =