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. Quote Link to comment 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? 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.