Hi there, I was wondering if any of you guys on here can help me with this.

I'm a total newbie when It comes to AJAX and Javascript in general so forgive me if this is really simple.

I have a script that I found on www.captain.at which basically allows an html form to be submitted, processes the corresponding php file and shows the result.

The code is as follows

Code:
<script type="text/javascript" language="javascript">
			var http_request = false;
			function makePOSTRequest(url, parameters) {
			http_request = false;
			if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
			}
			} else if (window.ActiveXObject) { // IE
			try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
			}
			}
			if (!http_request) {
			alert('Cannot create XMLHTTP instance');
			return false;
			}
			http_request.onreadystatechange = alertContents;
			http_request.open('POST', url, true);
			http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			http_request.setRequestHeader("Content-length", parameters.length);
			http_request.setRequestHeader("Connection", "close");
			http_request.send(parameters);
			}
			function alertContents() {
			if (http_request.readyState == 4) {
			if (http_request.status == 200) {
			//alert(http_request.responseText);
			result = http_request.responseText;
			document.getElementById('addfriend').innerHTML = result;
			} else {
			alert('There was a problem with the request.');
			}
			}
			}
			function get(obj) {
			var poststr = "userID=" + encodeURI( document.getElementById("userID").value ) +
			"&friendID=" + encodeURI( document.getElementById("friendID").value );
			makePOSTRequest('requests/addFriend.php', poststr);
			}
		</script>
And this is the code used for the form

Code:
<form action="javascript:get(document.getElementById('addfriend'));" name="addfriend" id="addfriend"> 
<input type="hidden" id="userID" value="{me.id}"> 
<input type="hidden" id="friendID" value="{user.id}"> 
<input type="button" name="button" value="Add to friends" onclick="javascript:get(this.parentNode);" class="ajaxbutton"> 
</form>
Now this works perfectly however I have more than one request I need to process in this way. The above code lets a user add another user to their friends list. I need the users to be able to add users to their favorites list also, and this would be done through a separate form.

What changes need to be made to the javascript code to allow me to have multiple forms leading to different php files on one page.

Any help would be greatly appreciated.

Thanks