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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.