I am trying to use this function to get the for data :
Expand|Select|Wrap|Line Numbers
- function getform(divid) {
- var getstr='';
- var obj=document.getElementById(divid)? document.getElementById(divid) : document.forms[divid];
- for (i=0; i<obj.childNodes.length; i++) {
- if (obj.childNodes[i].tagName == "INPUT") {
- if (obj.childNodes[i].type == "text") {getstr +="&" + obj.childNodes[i].name + "=" + obj.childNodes[i].value;}
- if (obj.childNodes[i].type == "hidden") {getstr +="&" + obj.childNodes[i].name + "=" + obj.childNodes[i].value;}
- if (obj.childNodes[i].type == "password") {getstr +="&" + obj.childNodes[i].name + "=" + obj.childNodes[i].value;}
- if (obj.childNodes[i].type == "checkbox") { if (obj.childNodes[i].checked) {getstr +="&" + obj.childNodes[i].name + "=" + obj.childNodes[i].value;} else { getstr +="&" + obj.childNodes[i].name + "=off"; }}
- if (obj.childNodes[i].type == "radio") { if (obj.childNodes[i].checked) {getstr +="&" + obj.childNodes[i].name + "=" + obj.childNodes[i].value;} else { getstr +="&" + obj.childNodes[i].name + "=off"; }}}
- if (obj.childNodes[i].tagName == "SELECT") {var sel = obj.childNodes[i]; getstr +="&" + sel.name + "=" + sel.options[sel.selectedIndex].value;}}
- return getstr;}
it works ok,
but when my fields are in a table it doesn't work, it finds the "table" tag as the childnode instead of input or select.
how can i make this work with tables?