0

Dear All,
I have form where I add dynamic html element as below. In the php code via ajax I have built the full drop down list. So when I post the form in IE when I do like this $masterID=$_POST; I am able to capture the form value. But in both firefox and chrome it shows me empty. Any solution please?

function getMaster(entID,nextElement)
{
var table = document.getElementById('myTable');               
var rowCount = table.rows.length; 
//alert("Row count : "+rowCount);
  
if(rowCount>2)
{            
	for(var i=2; i<rowCount; i++) 
	{                 
		var row = table.rows[i];                 
		                     
			table.deleteRow(i);                     
			rowCount--;                     
			i--;                 
	}
}

differentiator=Math.floor(Math.random()*50000);
//if (str=="")
 // {
 // document.getElementById("cbTrailerList").innerHTML="";
 // return;
 // } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    	//alert("Test : "+xmlhttp.responseText);
    //document.getElementById("cbTrailerList").innerHTML=xmlhttp.responseText;    
      var x=document.getElementById('myTable').insertRow(2); 
      var y=x.insertCell(0); 
      var z=x.insertCell(1); 
      y.innerHTML="<label class=description for=element_1>Master <font color='red'>*</font></label> "; 
      z.innerHTML=xmlhttp.responseText;
      var a=document.getElementById('myTable').insertRow(3); 
      var b=a.insertCell(0); 
      var c=a.insertCell(1); 
      b.innerHTML=""; 
      c.innerHTML="<p class=error id='masterIDError'>"; 
    
     if(nextElement=="trailer")
      {
       getTrailer(entID);
      }
     else
      {
       getSlaves(entID);
      }
    }
    
  }
xmlhttp.open("GET","getMasterList.php?e="+entID+"&d="+differentiator,true);
xmlhttp.send();


}
2
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by newbie14
0

You could try to add 'masterID=' + document.getElementById('masterID').value in send(), assuming that the input element has that id. But I've always found ajax a pain, without a library.

0

Dear Twiss,
Is this what your meant? xmlhttp.send('masterID=' + document.getElementById('masterID').value );. But why I dont understand IE it works fine without problem but just firefox and chrome. I thought supposing IE got more problem then the rest.

0

Yes. I'm not sure what the problem is, but using a library helps a lot for ajax imho.

0

Dear Twiss,
What library are you suggesting? Or is there any other solution to this problem? Thank you.

0

Perhaps jquery or prototype, or a library that's specifically for ajax and nothing else.

0

Dear Twiss,
But why it works well for IE then without any problem?

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.