Right, my problem is that i want to place a hyperlink (or a button, i am not really concerned about what it looks like for the time being) within a quite large form that i want to use to pass some variables to another page. I have already tried something along the lines of:

echo "
<form name = 'newForm' action = 'index.php' method = 'post'>
        <input type = 'hidden' name = 'name1' value = '$var1' />
	<input type = 'hidden' name = 'name2' value = '$var2' />
	<input type = 'hidden' name = 'name3' value = '$var3' />
	<a href = \"javascript:document.getElementById('newForm').submit();\">Submit new form</a>
</form>
";

However, i am using a javascript that requires the original (more important) form to not be interrupted with another form.

The reason i want to be able to send this information to the post array is that the original form needs to use the post array for security and size reasons (the size of the form is dynamic depending on user input and could easily exceed over 500 arguments being passed on a regular basis). I would like to keep the whole site using the post array so that i am not constantly checking between the $_GET and $_POST arrays for the variables i need.

Thanks for reading and also any help you could provide.

What you are talking about is ajax, no?

I would prefer to not use ajax as i am not familiar with javascript really beyond modifying the DOM.

I would prefer to not use ajax as i am not familiar with javascript really beyond modifying the DOM.

If you know how to modify the dom then you should find this very simple. You just need to decide to do it. I will give you a very simple function that you can use.

//the ajax object for all ajax functions [do not modify this function]
function ajaxObject()
{
	var objectsuccess = true;
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				objectsuccess = false;
			}
		}
	}
	
	if(objectsuccess == false)
	{
		alert("Your browser does not support AJAX!");
		return false;
	}
	else
	{
		return xmlHttp;
	}
}

//process ajax post request
function getProdServ()
{
	var xmlHttp = ajaxObject(); //do not modify
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4) //run once ajax request responds
		{
			var response = xmlHttp.responseText;
			document.getElementById("addProdServ").innerHTML = response;
		}
	}
	
	xmlHttp.open("POST","pathandfilename.php",true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); //do not modify
	
	//leave off the innitial "?"
	xmlHttp.send("variable1=value&variable2=value&variable3=value");
}
This article has been dead for over six months. Start a new discussion instead.