Hi there, I'm making a script that gets a form's elements, and writes them to an XMLHttpRequest. It works perfectly with inputs, but when it switches to text areas, it returns "undefined" :\
Could you help me find the error? :D
function sendForm(target, form)
{
var item;
var string="";
var content=form.elements;
for (item in content)
{
if (content[item].tagName=="INPUT")
{
if (content[item].type!="submit" && content[item].type!="radio")
{
if (item!=content.length-1)
{
string=string+content[item].name+"="+content[item].value+"&";
}
if (item==content.length-1)
{
string=string+content[item].name+"="+content[item].value;
}
}
if (content[item].type=="radio" && content[item].checked==true)
{
if (item!=content.length-1)
{
string=string+content[item].name+"="+content[item].value+"&";
}
if (item==content.length-1)
{
string=string+content[item].name+"="+content[item].value;
}
}
}
if (content[item].tagName=="TEXTAREA")
{
if (item!=content.length-1)
{
string+=content[item].name+"="+content[item].value+"&";
}
if (item==content.length-1)
{
string+=content[item].name+"="+content[item].value;
}
}
}
if (string[string.length-1]=="&")
{
string=string.substr(0, string.length-1);
}
if (window.XMLHttpRequest)
{
request=new XMLHttpRequest();
}
else
{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
request.open("POST", target, true);
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.send(string);
}