How to? Form Post to Multiple Locations

How To ? Form Post to Multiple Locations

The best way to go about it would be to first submit the form to your local script, then use CURL to POST the (filtered) data that was received to the remote script. Then just watch for the response.

Then simply send the email and process the response from the remote script in your local one.

Submit same form to multiple locations without Javascript

I think you have the best non-javascript solution - certainly hte way I'd run with it.

One thing to make it easier is that you can use multiple inputs with the same name:

<input name="tablerow[]" type="text" value="A" />
<input name="tablerow[]" type="text" value="B" />
<input name="tablerow[]" type="text" value="C" />

And these come through the $_POST['tablerow'] as an array. The length of the array is the number of fields. Then add additional fields to that.


For accessibility, you should add a link at the top that allows the user to hop directly to the first "new" field - otherwise they need to tab through the entire form to get to the new field. (See my comment above about if JS is really unavoidable as you and they can avoid this scenario!)

Multiple form tags in different locations with the same target iframe?

UPDATE 2

To get a cleaner result without the stale cache confusing tests I have updated it, please review newest update:

http://plnkr.co/edit/34KOyh9rIEGV3bXNsD9F?p=preview


UPDATE

Now that I was provided with a very complete and nicely coded demo, I have solved your problem.

http://plnkr.co/edit/Z2I1Q2swIXmFfynalaLB?p=preview

Note: I'm using a test server, so the cache may be stale. Just change the action by adding a number to the end.

Example

change:

http://www.hashemian.com/tools/form-post-tester.php/so_post_chk

to:

http://www.hashemian.com/tools/form-post-tester.php/so_post_chk1
  • When the checkbox is checked, your result should be cache=on

  • When the checkbox is not checked, your result should be cache=


You could assign one or more inputs (usually type="hidden") outside of the forms and collect whatever data from anywhere on the page regardless of which form it originated from.

http://plnkr.co/edit/er5RoJ049xSBwtR7gtTI?p=preview

This demo revolves around a simple JS function:

    function toOutput(x) {
var str = x.toString();
var out4 = document.getElementById('out4');
out4.value += str;
}

Note the special condition for checkboxes:

    if(this.checked) {
toOutput(this.value);
text1.value += this.value;
};

It's needed because when the click event is triggered on a checkbox, it is considered on every click checked and unchecked. I assume that the checkbox value is collected when it's actually checked.

Adding multiple records on a form using jquery

UPDATE
Correct answer is in comments below:
Create a "Location" table in the db with each location, and all of the fields associated with it. Then you can just use the location id in your array, and then when iterating through the array you can pull all of the associated fields for that location id.

If you're using JQuery UI you may want to consider some of the JQuery MultiSelect Plugins:

http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/

http://plugins.jquery.com/project/jquery-multiselect

To get the checked values to display to the user on the form, as well as if there are any errors, call the appropriate method ('getChecked' if you're using the jQuery UI MultiSelect Widget) to get an array of all the checked checkboxes.

HTML form with multiple actions

As @AliK mentioned, this can be done easily by looking at the value of the submit buttons.

When you submit a form, unset variables will evaluate false. If you set both submit buttons to be part of the same form, you can just check and see which button has been set.

HTML:


<form action="handle_user.php" method="POST" />
<input type="submit" value="Save" name="save" />
<input type="submit" value="Submit for Approval" name="approve" />
</form>

PHP


if($_POST["save"]) {
//User hit the save button, handle accordingly
}
//You can do an else, but I prefer a separate statement
if($_POST["approve"]) {
//User hit the Submit for Approval button, handle accordingly
}

EDIT


If you'd rather not change your PHP setup, try this: http://pastebin.com/j0GUF7MV

This is the JavaScript method @AliK was reffering to.

Related:

  • 2x submit buttons to action different URL
  • Submit form to another page (which is different from the page used in ACTION)

Codeigniter form submit to multiple places

Use flashdata, and store the email address in a flashdata variable.

$this->session->set_flashdata('email', $email);

Keep in mind that you will need to "keep" the flashdata if it is not used in the next request, otherwise it will disappear.

$this->session->keep_flashdata('email');

Then, set the $email variable for the view to $this->session->flashdata('email');

Two submit buttons in one form

If you give each one a name, the clicked one will be sent through as any other input.

<input type="submit" name="button_1" value="Click me">

can a form have multiple targets?

Forms can only have a single target.

Instead, you can use JavaScript to catch the submit event on your form and programmatically set the src attributes of all iframes.

You can do that using the vanilla FormData or for example using jQuery's serialize().

UPDATE (jQuery example):

$("form[target=Charts]").on("submit", function(event) {
event.preventDefault();
var baseSrc = $(this).attr('action');
var queryArgs = $(this).serialize();
$('iframe[name=Charts]').each(function() {
$(this).attr('src', baseSrc + '?' + queryArgs);
});
});


Related Topics



Leave a reply



Submit