Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form not working when one checkbox checked.

    Hi

    I have a test form here, but will post the code below in case..
    http://www.virtuallee.co.uk/Sunrise_...uktesting.html

    When the form is submitted, the contents are emailed to me.
    However, if only one checkbox is checked within 'Which location interests you', I don't receive an email.
    If more than one checkbox from 'Which location interests you' is checked then I do receive an email.

    Would really appreciate it if anyone could tell me why it's not working for just one checkbox checked? I don't think it has anything to do with the php based page...it must be something to do with the script in the html page.

    There are 2 pages, which can be easily copied to test locally:
    email-form-uktesting.html
    and send-uktesting.php

    Here's the code for email-form-uktesting.html
    <script type="text/javascript" language="Javascript">
    <!-- Preload Script
    function preload() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preload.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    // End Preload Script -->
    function submitForm(){
    var emailAddress = '';
    var varLocation = '';
    var errorMessage = '';
    if (document.frmKontakt.locationCheck[0].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Frognal House, ';
    }
    if (document.frmKontakt.locationCheck[1].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Elstree, ';
    }
    if (document.frmKontakt.locationCheck[2].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Virginia Water, ';
    }
    if (document.frmKontakt.locationCheck[3].checked){
    emailAddress += 'lee@virtuallee.co.ukk,';
    varLocation += 'Banstead, ';
    }
    if (document.frmKontakt.locationCheck[4].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Purley, ';
    }
    if (document.frmKontakt.locationCheck[5].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Fleet, ';
    }
    if (document.frmKontakt.locationCheck[6].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Edgbaston, ';
    }
    if (document.frmKontakt.locationCheck[7].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Westbourne, ';
    }
    if (document.frmKontakt.locationCheck[8].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Guildford, ';
    }
    if (document.frmKontakt.locationCheck[9].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Bassett, ';
    }
    if (document.frmKontakt.locationCheck[10].checked){
    emailAddress += 'lee@virtuallee.co.uk,';
    varLocation += 'Esher';
    }
    if (document.frmKontakt.Name.value == ""){
    errorMessage = 'Please input your Name\n'
    }
    if (document.frmKontakt.address01.value == ""){
    errorMessage = errorMessage + 'Please input your Address\n'
    }
    if (document.frmKontakt.Postcode.value == ""){
    errorMessage = errorMessage + 'Please input your Postcode\n'
    }
    if (document.frmKontakt.Phone.value == ""){
    errorMessage = errorMessage + 'Please input your Telephone number\n'
    }
    if (emailAddress == ''){
    errorMessage = errorMessage + 'Please input the Location(s) you are interested in';
    }
    if (errorMessage != ''){
    alert(errorMessage);
    }
    else{
    document.frmKontakt.location.value = varLocation;
    var checked = 0;
    emailAddress = 'lil@virtuallee.co.uk';
    for (i=0;i<document.frmKontakt.locationCheck.length;i++) {
    if (document.frmKontakt.locationCheck[i].checked) {
    checked++;
    }
    }
    if (checked > 1) {
    emailAddress = 'info@theportraitpainter.co.uk';
    }
    document.frmKontakt.ToEmail.value = emailAddress;
    var varServices = '';
    if(document.frmKontakt.servicesCheck[0].checked){
    varServices += 'Assisted Living, ';
    }
    if(document.frmKontakt.servicesCheck[1].checked){
    varServices += 'Dementia Care, ';
    }
    document.frmKontakt.services.value = varServices;
    document.frmKontakt.submit();
    }
    }
    </script>

    Here's the code for send-uktesting.php

    <?php
    $to = $_POST['ToEmail'];
    $Title = $_POST['Title'];
    $Name = $_POST['Name'];
    $address01 = $_POST['address01'];
    $address02 = $_POST['address02'];
    $address03 = $_POST['address03'];
    $Postcode = $_POST['Postcode'];
    $Telefon = $_POST['Phone'];
    $Mobil = $_POST['Mobile'];
    $Email = $_POST['Email'];
    $who = $_POST['who'];
    $services = $_POST['services'];
    $location = $_POST['location'];
    $contact = $_POST['contact'];
    $time = $_POST['time'];
    $comments = $_POST['comments'];
    $message = "Feedback from www.sunrise-care.co.uk: \n ".$Title." ".$Name."\n Address: ".$address01.", ".$address02.", ".$address03.", ".$Postcode.".\n Phone: ".$Telefon."\n Mobile: ".$Mobil."\n Email: ".$Email."\n On whose behalf are you enquiring?: ".$who."\n Which of our services interest you?: ".$services."\n Which of our current locations interest you?: ".$location."\n How would you most like us to contact you?: ".$contact."\n For telephone contacts, at which time of day should we call you?: ".$time."\n Comments: ".$comments;
    mail($to, "www.sunrise-care.co.uk Feedback", $message, "From:".$Email,"-fuser@http://www.sunrise-care.co.uk/");
    //echo $to;
    header("Location: http://www.sunrise-care.co.uk/contact-us/thanks.html");
    ?>

    Thanks!
    Lee
    Last edited by leeollie; 07-13-2005 at 07:58 PM.

  • #2
    New Coder
    Join Date
    Jul 2005
    Location
    Virginia
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It may be a typo, but check the email address in line 40...

    emailAddress += 'lee@virtuallee.co.ukk,';


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •