/    Sign up×
Community /Pin to ProfileBookmark

Submitting to multiple locations

Hi,

Can someone tell me the easiest way to submit a form to multiple locations depending on what button the user presses?

Note: The form data needs to be submitted.

Currently, I have tried something like:
<input type=”button” onClick=”document.myForm.submit(‘submit_page.php’)” value=”Display” />

Although this does not work because the submit parameter is useless as far as I can tell (unless it is empty). Is the only option using a page of javascript?

Regards,

Tim

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzNov 18.2005 — Why do you want to submit your form to more than one location?

The onclick function [b]is[/b] JavaScript. Though the submit() method of form elements does not have any paramaters/arguments.

You could use JavaScript to switch the form's action, however, you should [url=http://www.thecounter.com/stats/2005/October/javas.php]keep in mind that about 10% of Internet users use a browser that doesn't have JavaScript enabled.[/url]
Copy linkTweet thisAlerts:
@Tim158authorNov 18.2005 — I have a dynamically generated page with a list of checkboxes. The user needs to perform multiple operations on the selected records, such as Print, View Details, Transfer etc.

I don't mind using javascript but I'm trying to be economical with the amount of code I use.

The code I am working on will be used on an intranet where I know that IE will be used. I am using Konqueror on PC-BSD to develop it though.
Copy linkTweet thisAlerts:
@ranjithNov 18.2005 — Tim,

if u are ready to use javascript u can write a javascript function for eacj button and where u can write window.open(url) such tht u can submit to mulitiple locations .

i think it may work i am not sure try it out.
Copy linkTweet thisAlerts:
@Tim158authorNov 18.2005 — Yes that will go to a different URL but it will not pass the selected values to the URL - I need the form data.

Thanks though.
Copy linkTweet thisAlerts:
@Tim158authorNov 18.2005 — I've found a way of getting around the problem...

First I created a hidden field and gave it the name action.

I then just added another submit button like this:

<input type="submit" onmousedown="document.myform.action.value='print'" value="Print Selected" />

Ultimately the form still goes to the same location, but from there PHP can decide which action to take from the value in the action variable.
×

Success!

Help @Tim158 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...