0

Hello I need to pass an array of client side events to the next page. Here my user would perform a few events which would be stored in a javascript array, upon completion a submit button would be used to post all that data to the next page.

An example of such a process is listed below, could anyone help me returning that array back to php so that I can post it to the next page. I am trying to populate different entries made into textbox into the array arr. And when I would click the submit button, I want to post that array.

<html>
<head>
<script type='text/javascript'>

function retText(form)
{
var x = form.txtBox.value;
var arr = new Array();
 arr[arr.length]= x;
      return arr;
}

</script>
</head>
<body>
<form name='form' method='post' action=''>
<input type='text' name='txtBox' />
<input type='button' name='click' value='clickme' onclick='retText(this.form)' />
<input type='submit' name='submit' value='submit' />
</form>
</body>
</html>

I want to return that arr back and on post I want to send that array to the next page.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
2
Replies
6
Views
7 Years
Discussion Span
Last Post by jino
0

pass them using post or get then you can access them with php on the page they are submitted to. If your trying to add items before sending then create a hidden field and update that fields value property so whey you submit the information you can access that fields value. If the value is stored as item, item, item you can then use php to separate those fields into an array using the explode function.

0
<!--load the jquery page here-->
            

$("#submit").click(function(){

// get the values of the array using jquery from the submit form.  

                var Protocol	= location.protocol;
		var Host		= location.host;
		var Url	= Protocol+"//"+Host+"/nextpage";
		var dataString	= 'arrayvalue='+array;
		
		$.ajax({
			
			type: "POST",
			url: Url,
			data: dataString,
			cache: false,
			
			success: function(html){
				
				// tell jquery to do what after succes
				$("#rightSideContentDiv").html(html);
				// Here the html which is a view page is loaded into a div having id rightSideContentDiv in the same page.
			}
		});
                return false;
});

Edited by Ezzaral: Added code tags. I shouldn't have to do this for someone who has 97 posts.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.