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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.