user123
user123

Reputation: 5407

POst data to multiple file on form submit

I have button inside form. On button click, I submit form and post some var data to file.

<form action="data.php" method="POST" onsubmit="showUser(this, event)">

Here is it possible to post multiple file.

Like to data1.php and data2.php in above case?

something like showUser1() should poast to data1.php and showuser2() to data2.php.

possible?

Upvotes: 0

Views: 49

Answers (1)

user399666
user399666

Reputation: 19879

You can change the action of a form using JavaScript. Here, I've given your form an ID:

<form id="myForm" action="data.php" method="POST" onsubmit="showUser(this, event)">

Example JavaScript to change the action attribute of a form:

var frm = document.getElementById('myForm') || null;
if(frm) {
   frm.action = 'data1.php' 
}

or

var frm = document.getElementById('myForm') || null;
if(frm) {
   frm.action = 'data2.php' 
}

Note that this won't work if the user has decided to disable JavaScript. i.e. You can't fully rely on it.

Upvotes: 2

Related Questions