vincea Posted May 8, 2007 Share Posted May 8, 2007 Hey everyone, I always use the AJAX GET request to then make a request to a PHP document.. works great but before I haven't done it with the form behind a table. Here is an example of what I mean. the html: <form name="blah" id="blah"> <table> <tr> <td><input type="text" name="blah2" id="blah2"></td> </tr> <tr> <td><input type="button" name="submitit" value="submitme!" onclick="get(this.parentNode);"></td> </tr> </table> </form> the js: function get(obj) { var getstr = "?"; 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 == "checkbox") { if (obj.childNodes[i].checked) { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } else { getstr += obj.childNodes[i].name + "=&"; } } if (obj.childNodes[i].type == "radio") { if (obj.childNodes[i].checked) { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } } } if (obj.childNodes[i].tagName == "SELECT") { var sel = obj.childNodes[i]; getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&"; } if (obj.childNodes[i].tagName == "TEXTAREA") { var sel = obj.childNodes[i]; getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } makeRequest('thephp.php', getstr); } } I can never get this to work from behind a table. Mostly because the childNodes picks up the table Nodes and not the form Nodes. Any idea is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/50528-ajax-get-request-from-behind-a-table/ Share on other sites More sharing options...
vincea Posted May 9, 2007 Author Share Posted May 9, 2007 I actually figured this out without doing anything. So if anyone needs a script to run a Get request from a form.. I suggest: http://projects.aphexcreations.net/ajform/ works really well. Link to comment https://forums.phpfreaks.com/topic/50528-ajax-get-request-from-behind-a-table/#findComment-248951 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.