camilahlah 0 Newbie Poster

I need to get the values of all textboxes that I've generated through dropdown list using AJAX. I've been getting only the last value of the textbox, I can' seem to loop it. Anyway, here's my code:


$tag = $_REQUEST['tag'];
$ProjectName  = $_REQUEST['ProjectName'];
$Description = $_REQUEST['Description'];
$textboxes = $_REQUEST['textboxes'];


	//$insert = mysql_query("INSERT INTO tProject (ProjectName, Description, Pump) VALUES ('$ProjectName','$Description', '$textboxes')") or die (mysql_error());
	echo "Saved!";

	<script type="text/javascript" src="ajaxhandler.js">



<form method = "POST">

Project Name: 
	<input type="text" id="ProjectName"><br>

	<input type="text" id="Description"><br>

<select name="boxes" onchange="Pump(this.value);">
	<option value="">choose</option>
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
	<option value="4">4</option>
	<option value="5">5</option>
	<option value="6">6</option>
	<option value="7">7</option>
	<option value="8">8</option>
	<option value="9">9</option>
	<option value="10">10</option>
<div id='textboxes'>
<div id='textboxes1'>

<input type="button" onclick=chpage('AddP.php?tag=A') value="Save">
<input type="button" value="Clear">


My AJAX code:

function chpage(url){ 
	var xmlHttp = getXMLHttp();
	        if ( url == "AddP.php?tag=A") 
			var x= document.getElementById('ProjectName').value;
			var y= document.getElementById('Description').value;
		  	cn = document.getElementById( "textboxes" ).childNodes;
 			for (var i = 0; i < cn.length; i++) 
    				var a = cn[i].value;
    					var strURL = url + "&ProjectName=" + x + "&Description=" + y + "&textboxes=" + a;

		else {
			var strURL =url;
  xmlHttp.onreadystatechange = function()
    if(xmlHttp.readyState == 4)
        document.getElementById('loading').style.visibility = "hidden";
	document.getElementById('loading').style.visibility = "visible";"GET", strURL, true);

Any help would be very much appreciated. Thank you. =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.