Wednesday 14 July 2021

HTML Assigning the checkbox to the form action already defined

I have the form with action targeted for the specified task. I want to have this form also sent by email. It can be the :mailto option or other. Mailto on submit button enter image description here

So When I click the Submit form, the form is submitted. However I would like to attach another action to this action, namely I would like to send this filled form to the email by checking the ckeckbox.

So far I saw, that sending the form by checkbox is possible:

submitting a form when a checkbox is checked

but the pivot thing here is assigning the other form action to my form...

HTML form with multiple "actions"

I tried something like this:

  <form id="c_form"  action="default_url_when_press_enter" method="get" onsubmit="return validate(this);" target="_blank" >

  ....

  <input type="checkbox" action="mailto:mk@gmail.com" id="cfemail" name="email">
  <input class="btn" action="c_form.html" type="submit" id="cfsubmit" value="Submit form">

but it didn't work unfortunately as well as with the code applied below:

   document.getElementById("cfsubmit").addEventListener("click", function(){
                                                                
    document.getElementById("c_form").className="submitted";
                                                            });

How can I send email along with the form submission when my box is checked?

The full code is available here:

https://jsfiddle.net/ptgbvfen/



from HTML Assigning the checkbox to the form action already defined

No comments:

Post a Comment