ginerjm Posted March 22, 2012 Share Posted March 22, 2012 I have a button that has the following: onclick="confirmDeleteEvent($i)" in my php code. My JS code is: function confirmDeleteEvent(i) { frmname = 'entform'+i; alert("in confirmdelete with "+frmname); var ans = confirm("You will delete this event and any associated partner data. OK?"); if (ans) { document.getElementById(frmname).submit(); } return; } My alerts tell me that I have values in the JS that make sense to me. Yet I can't get it to accept the submit call. Message is "object doesn't support this property or method". What am I doing wrong? I have tried many different ways (that I found on the net) which also don't work. Amazing how many tips are out there that are just plain wrong. Quote Link to comment https://forums.phpfreaks.com/topic/259505-form-submission/ Share on other sites More sharing options...
AyKay47 Posted March 22, 2012 Share Posted March 22, 2012 I'm going to take a stab at this one, not 100% sure. I believe the error is happening because the object that you are creating inside of the function is not available outside of its scope. Try passing the form object into the function via is argument list. Quote Link to comment https://forums.phpfreaks.com/topic/259505-form-submission/#findComment-1330263 Share on other sites More sharing options...
ginerjm Posted March 22, 2012 Author Share Posted March 22, 2012 Here is what finally worked. in my html i have a button that has ... onclick="confirmDeleteEvent(this.form)".... in my js function I do this: function confirmDeleteEvent(thisfrm) { var ans = confirm("You will delete this event and any associated partner data. OK?"); if (ans) thisfrm.submit(); else return; } Don't know what the resonse about objects being out of scope means. But this code definitely works! Quote Link to comment https://forums.phpfreaks.com/topic/259505-form-submission/#findComment-1330267 Share on other sites More sharing options...
AyKay47 Posted March 22, 2012 Share Posted March 22, 2012 well, the code you posted backs up what I stated. Glad you got it. Quote Link to comment https://forums.phpfreaks.com/topic/259505-form-submission/#findComment-1330277 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.