我不能再单击表单中的复选框了吗?

I can no longer click the checkboxes in my form?

在处理包含大量文本和复选框输入的 "sign-up" 类型表单时,我更改了一些内容,不再允许我使用鼠标来选中或取消选中我的复选框,但我不会确定什么。

奇怪的是(无论如何对我来说),如果我选择任何给定的复选框并使用 space 栏,该复选框将根据需要选中或取消选中。

我更改了 "name" 并添加了 "value" 以使我的表单数据正确填充到 PHP 驱动的电子邮件中。我需要这些才能使 PHP 在我设置时正常工作,但我已经尝试返回并删除这些更改作为测试,但我仍然无法使用鼠标来检查或取消选中甚至恢复到可以正常工作的原始代码后。

我是不是遗漏了什么明显的东西?有什么建议吗?

有问题的页面在这里:www.vg4v.com/register-your-guide-service.html

我原来的测试页面(复选框起作用的地方)是 here

当前HTML:

<ul class="button-list">
<!--  Available Activities Checkboxes -->
    <li><input type="checkbox" name="sport[]" value="Fishing"><label for="fish">Fishing</label></li>
    <li><input type="checkbox" name="sport[]" value="Fly-fishing"><label for="fly-fish">Fly Fishing</label></li>
    <li><input type="checkbox" name="sport[]" value="Hunting"><label for="hunt">Hunting</label></li>
    <li><input type="checkbox" name="sport[]" value="Boat Charters"><label for="charter">Boat Charters</label></li>
    <li><input type="checkbox" name="sport[]" value="HIking"><label for="hike">Hiking</label></li>
    <li><input type="checkbox" name="sport[]" value="Rafting or Paddling"><label for="raft">Rafting/Paddling</label></li>
    <li style="width:auto;"><input type="text" name="other_sports" id="other_sports" value="" placeholder="Something we missed?"></li>                                          
</ul>

原文HTML:

<ul class="button-list">
    <li><input type="checkbox" name="sport" id="fish"><label for="fish">Fishing</label></li>
    <li><input type="checkbox" name="sport" id="fly-fish"><label for="fly-fish">Fly Fishing</label></li>
    <li><input type="checkbox" name="sport" id="hunt"><label for="hunt">Hunting</label></li>
    <li><input type="checkbox" name="sport" id="charter"><label for="charter">Boat Charters</label></li>
    <li><input type="checkbox" name="sport" id="hike"><label for="hike">Hiking</label></li>
    <li><input type="checkbox" name="sport" id="raft"><label for="raft">Rafting/Paddling</label></li>
    <li style="width:auto;"><input type="text" name="other-sports" id="other-sports" value="" placeholder="Other services?"></li>                                           
</ul>

我的PHP:

<?php
if(!isset($_POST['submit']))
{
    //This page should not be accessed directly. Need to submit the form.
    echo "error; you need to submit the form!";
}
$company = $_POST['company']; 
//top fields
$name = $_POST['name'];   
$phone = $_POST['phone']; 
$visitor_email = $_POST['email'];
$license = $_POST['license'];     
$address = $_POST['address']; 
$website = $_POST['website'];     
$facebook = $_POST['facebook'];
//checkboxes
foreach($_POST['sport'] as $value) {
$sport_msg .= "$value\n";
}
$other_sports = $_POST['other_sports'];
foreach($_POST['availability'] as $value) {
$availability_msg .= "$value\n";
}
foreach($_POST['season'] as $value) {
$season_msg .= "$value\n";
}
//bottom text boxes
$equipment = $_POST['equipment'];     
$veteranmessage = $_POST['veteranmessage'];


//Validate first
if(empty($company)||empty($name)||empty($visitor_email)||empty($phone)||empty($license)||empty($address)||empty($equipment)) 
{
    echo "Name and email are mandatory!";
    exit;
}

if(IsInjected($visitor_email))
{
    echo "Bad email value!";
    exit;
}

$email_from = 'VGFV Guide Signup';//<== Shows up in the "from" field
$email_subject = "New Guide Signup";//<==  Email Subject

//Begin Email Body

$email_body = "$name has signed up from $company\n\n".
    "Here is their info:\n\n".
    "COMPANY NAME: $company \n\n".
    "GUIDE'S NAME: $name \n\n".
    "PHONE NUMBER: $phone \n\n".
    "EMAIL ADDRESS: $visitor_email \n\n".
    "LICENSE STATE & NUMBER: $license \n\n".
    "HOME BASE: $address \n\n".
    "WEBSITE: $website \n\n".
    "FACEBOOK/SOCIAL MEDIA ADDRESS: $facebook \n\n".    
    "GUIDE SERVICES OFFERED: \n$sport_msg \n\n".

    "AVAILABILITY: \n$availability_msg \n\n".
    "SEASONS: \n$season_msg \n\n".
    "EQUIPMENT PROVIDED: \n$equipment \n\n".
    "NOTE FROM THE GUIDE: \n$veteran-message \n\n".     


$to = "steve@4sdesignstudio.com";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');


// Function to validate against any email injection attempts
function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}

?>

您的复选框不再 "checking" 的原因是您需要为所有复选框重新添加所有 id 标签。

  • 这是根据在我的机器上本地测试并在评论中概述的。

  • id="fish"><label for="fish">

同时对其他人遵循相同的命名约定。