Multiple submit buttons in a single form

Prototype only :/

Hello - this code snippet will allow you to submit a form with multiple submit buttons to different targets..
The Implementation is very Simple:
put the following code either inside a
tag on your page or put it in a separate js file

Next you have to Configure your buttons:
Set their class to "multiplesubmit" and their rel to that page where your form should be submitted

You're done

The js-code:
	
/*
	this snippet will allow to submit a single form with different buttons to different locations
	usage: set the class "multiplesubmit" to your buttons and a rel-attribute inside your button
	where the actionparameter of the form should go
	for example:
		<form method="post">
			<button rel="http://127.0.0.1/a.php" class="multiplesubmit">I submit to a.php</button>
			<button rel="http://127.0.0.1/b.php" class="multiplesubmit">I submit to b.php</button>
		</form>
*/

function submitMultiple(event)
{
	console.group("multi submit debug");

	var ele = event.currentTarget;
	console.info("pressed on:");
	console.info(ele);

	var rel = ele.readAttribute('rel');
	if (!rel)
	{
		console.error("You have to place the form action into the rel attribute of your button");
		event.stop();
		return false;
	}

	// finding the parent form
	var par = ele.up(0);
	while(par.tagName.toLowerCase() != 'form')
		par = par.up(0);
	if (!par)
	{
		console.error("You have to place your buttons inside a form");
		event.stop();
		return false;
	}
	console.log('got parent form:');
	console.log(par);
	var form = par;

	// setting the action of the form to that one inside rel
	console.info('set the form action to:');
	console.info(rel);
	form.action = rel;

	form.submit();
	event.stop();
	return false;
}

document.observe("dom:loaded", function() {
	$$('.multiplesubmit').each(function(d){d.observe('click', submitMultiple);});
});