I have html form, javascript ajax code and php code that sends email.
I have one problem.
My checkboxes are made with span (see code). How to check if this span with class checkmark are checked.
My html:
<form id="obrazec" class="form-inline"> <input class="okno" type="email" id="email" placeholder="Email" name="email" required> <input type="checkbox" id="trgovina" value="" name="trgovina">Spletna trgovina <span class="checkmark"></span> <input type="checkbox" id="oglasevanje" value="" name="oglasevanje">Oglaševanje <span class="checkmark"></span> <input type="checkbox" id="trgovina" value="" name="strani">Spletna stran <span class="checkmark"></span> <div class="submitdiv"> <button class="submit" id="potrdi" type="button" onclick>POŠLJI</button> </div> </form> My javascript:
<script type="text/javascript"> $(document).ready(function(){ $("button#potrdi").click(function(){ event.preventDefault(); var formData = $('#my_form').serialize(); var email = $("#email").val(); var boolMAIL = email.includes("@"); var dataString = 'email=' + email; if(boolMAIL == true ){ $.ajax({ url:"action_page.php", type: "POST", data: dataString, success:function(result){ $( ".response" ).show(); $( ".response2" ).hide(); $( "#obrazec" ).hide(); $( ".prijavatext" ).hide(); } }); } else { $( ".response2" ).show(); } }); }); </script> My php:
$email = $_POST['email']; $visitor_email = $_POST['email']; $email_from = '[email protected]'; $email_subject = "Novo povprasevanje"; $email_body = "Novo povprasevanje: $email.\n ". $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; $to = "[email protected]"; mail($to,$email_subject,$email_body,$headers); ?> It works ok (email) and i get mail but i don't know how to check if checkbox is checked because it is not check box actually but field:
<span class="checkmark"></span>
names andids.