Jump to content

form submission


ginerjm

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/259505-form-submission/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/259505-form-submission/#findComment-1330263
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/259505-form-submission/#findComment-1330267
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.