marf Posted June 7, 2007 Share Posted June 7, 2007 Anybody know if theres something special to get this.elements[0] working? I basically have my ajaxhttpreq.js which the function in that file has a for loop like ... for(var i=0;i<thisForm.elements.length;i++){ if(thisForm.elements[i].type == "text"){ formData = formData + thisForm.elements[i].name + "=" + escape(thisForm.elements[i].value) + "&"; } ... but formData is ALWAYS empty, no matter what. Why is this? I call this function with onSubmit = "return ajaxreq(this,"myfile.php");" in my <form> tag so that looks legit. Link to comment https://forums.phpfreaks.com/topic/54617-cant-get-thiselements-to-work-in-ajax/ Share on other sites More sharing options...
marf Posted June 7, 2007 Author Share Posted June 7, 2007 ok forget everything I said above as I have narrowed down the problem. I use this to call the javascript <form action="add_laptop2.php" onsubmit="return formSubmit(this, 'add_laptop2.php');" method="POST"> and then look below function formSubmit(thisForm, pageURL){ alert(thisForm.elements[0].value); //THIS WORKS AND Shows the Value secondFunction(thisForm); return false; } function secondFunction(thisForm){ alert(thisForm.elements[0].value); //THIS Doesn't show, the alert window shows undefined } So why does it not show in the second function but in the first one its fine? I tried assigning it to a variable in the first one and passing and still no go... any ideas? Link to comment https://forums.phpfreaks.com/topic/54617-cant-get-thiselements-to-work-in-ajax/#findComment-270261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.