Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么JavaScript CSS类破坏了这个脚本?_Javascript_Css - Fatal编程技术网

为什么JavaScript CSS类破坏了这个脚本?

为什么JavaScript CSS类破坏了这个脚本?,javascript,css,Javascript,Css,这是剧本- <script language=javascript> function apply() { document.form1.sub.disabled=true; if(document.form1.chk.checked==true) { document.form1.sub.disabled=false; } if(document.form1.chk.checked==false) { document.form1.sub.e

这是剧本-

<script language=javascript>
function apply()
{
  document.form1.sub.disabled=true;
  if(document.form1.chk.checked==true)
  {
    document.form1.sub.disabled=false;
  }
  if(document.form1.chk.checked==false)
  {
    document.form1.sub.enabled=false;
  }
}
</script> 

函数apply()
{
document.form1.sub.disabled=true;
if(document.form1.chk.checked==true)
{
document.form1.sub.disabled=false;
}
if(document.form1.chk.checked==false)
{
document.form1.sub.enabled=false;
}
}
如果我使用这个html,它不工作--


然而,这也不起作用--


但这确实有效--


因此,如果类“field”在其中,它将破坏JS。我当然可以把它拿出来,但我想知道为什么它不起作用

谢谢

编辑 对不起,伙计们,这是整页。CSS只是控制元素的位置,据我所知,它不应该干扰JS-

<?php
session_start();
if(!isset($_SESSION['referrer'])){
    //get the referrer
    if ($_SERVER['HTTP_REFERER']){
        $referrer = $_SERVER['HTTP_REFERER'];
    } else {
        $referrer = "unknown";
}
//save it in a session
$_SESSION[’referrer’] = $referrer; // store session data
}

//grab campaign var from url
$campaign = $_GET['campaign'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Beerfest Packages Sweepstakes - Blue Ridge Country</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="scripts/wufoo.js"></script>
<link rel="stylesheet" href="css/structure.css" type="text/css" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<link rel="stylesheet" href="css/theme.css" type="text/css" />
<script language=javascript>
function apply()
{
  document.form1.sub.disabled=true;
  if(document.form1.chk.checked==true)
  {
    document.form1.sub.disabled=false;
  }
  if(document.form1.chk.checked==false)
  {
    document.form1.sub.enabled=false;
  }
}
</script>  
</head>

<body id="public">

<img id="top" src="images/top.png" alt="" />
<div id="container">

<h1><a href="">Wufoo</a></h1>

<form class="wufoo" action="insert.php" method="post" name="form1">

    <div class="info">
        <h2>Register to Win &amp; Subscribe to Blue Ridge Country</h2>
        <div>Now's your chance to not only register to win our free beerfest tickets and getaway, but also receive the #1 magazine in the Blue Ridge Mountains!</div>
    </div>

    <ul>

    <li class="section first">
        <h3>Your information</h3>
        <div>Whether you're registering to win or subscribing to the magazine (or both!) we need your info!</div>
    </li>

    <li>
    <label class="desc">Name <span class="req">*</span></label>
        <span>
        <input class="field text" size="8" value=""/>
        <label>First</label>
        </span>

        <span>
        <input class="field text" size="3" value=""/>
        <label>M.I.</label>
        </span>

        <span>
        <input class="field text" size="14" value=""/>
        <label>Last</label>
        </span>
    </li>
    <li>
    <label class="desc">Email <span class="req">*</span></label>
        <div>
        <input class="field text medium" type="text" name="email" maxlength="100" value="" /> 
        </div>
        <p class="instruct">Don't worry, we won't spam you, share or sell your email address!</p>
    </li>    
    <li>
    <label class="desc">Address <span class="req">*</span></label>
        <div>
        <input class="field text medium" type="text" maxlength="100" value="" /> 
        </div>
    </li>
    <li>
        <span>
        <input class="field text" size="15" value="" />
        <label>City</label>
        </span>

        <span>
        <input class="field text" size="2" value="" />
        <label>State</label>
        </span>

        <span>
        <input class="field text" size="5" maxlength="10" value="" />
        <label>Zip</label>
        </span>
    </li>

    <li>
    <label class="desc">Phone <span class="req">*</span></label>
        <span>
        <input class="field text" type="text" size="3" maxlength="3" value=""/> - 
        <label>Area</label>
        </span>

        <span>
        <input class="field text" type="text" size="8" maxlength="8" value=""/>
        <label>Phone</label>
        </span>
    </li>    

    <li class="section">
        <h3>Legal mumbo jumbo</h3>
        <div>Don't worry, you're almost done and this is the last bit we need from you!</div>
    </li>

    <li>
    <label class="desc">Official Rules <span class="req">*</span></label>
        <div>
        <textarea rows="10" cols="50" class="field textarea medium" readonly="readonly" style="font-size: 0.8em;">1. To enter, complete an online request by submitting this completed form. Or, send a stamped, self-addressed envelope to: "Blue Ridge Country Beerfest Promotion," Leisure Publishing, PO Box 21535, Roanoke, VA 24018, requesting an entry form. Limited to one entry per household. Entries must be received by June 30, 2009. 2. Reservation procedures to come with notification of winning. Package not available during holidays and special events. Notification of prizes will be sent to winners at the email address on the entry form. The odds of winning will depend upon the number of entries. 3. All prizes will be awarded to winners selected by random drawing from all valid entries received. Drawing will be conducted by Leisure Publishing Inc., an independent publisher, whose decisions are final on all matters relating to this sweepstakes. Winners will be notified by email to the address provided on the entry form. Only one prize to a family or household. Due to the nature of this competition, you must be 21 or older to win. Proof of age will be required prior to receiving free tickets to alcohol-related events. 4. Sweepstakes is open to all residents of the U.S. and Canada except advertisers, their employees, their advertising and promotion agencies, and the families of each. Void wherever taxed, restricted or prohibited by law. Prizes are not transferable; may not be exchanged or substituted; cannot be redeemed for cash; must be taken in their entirety; no substitutions permitted. Taxes, if any, are the responsibility of the individual winners. 5. Entry in sweepstakes constitutes permission to use winners’ names and photograph for advertising and publicity purposes, without further compensation to winners. For names of prize winners, send a stamped, self-addressed envelope to: "Blue Ridge Country Beerfest Promotion" — Winners, P.O. Box 21535, Roanoke, VA 24018.</textarea>
        </div>
    </li>

    <li class="section">
        <h3>Subscribe / Win!</h3>
        <div>While you don't have to subscribe to win, we hope you will!</div>
    </li>

    <li>
    <label class="desc">Sweepstakes Selection</label>
        <div class="col">
        <span><input id="choice1" name="mc" class="field radio" type="radio" value="Robots" checked="checked" />
        <label class="choice" for="choice1">Robots</label></span>

        <span><input id="choice2" name="mc" class="field radio" type="radio" value="Monkeys"/>
        <label class="choice" for="choice2">Monkeys</label></span>
        </div>
    </li>

    <li>
    <label class="desc">Official Rules</label>
        <div class="col">
        <span><input class="checkbox" type="checkbox" name="chk" onClick="apply()" value="accept" />
        <label class="choice">I accept the terms and conditions from the "Official Rules" above.</label></span>
        </div>
    </li>    

    <li class="buttons">
        <input id="saveForm" class="btTxt" type="submit" name="sub" value="Submit" disabled="disabled" />
    </li>
    </ul>

    <div style="display: none;">
        <input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
        <input type="hidden" name="campaignID" value="<?php echo $campaign; ?>" />
    </div>

</form>

</div>

Beerfest套餐抽奖-蓝岭国家
函数apply()
{
document.form1.sub.disabled=true;
if(document.form1.chk.checked==true)
{
document.form1.sub.disabled=false;
}
if(document.form1.chk.checked==false)
{
document.form1.sub.enabled=false;
}
}
注册赢取&;订阅蓝岭国家
现在,您不仅有机会注册赢取我们的免费啤酒节门票和出游,还可以在蓝岭山脉获得#1杂志!
  • 你的信息 无论您是注册赢家还是订阅杂志(或两者皆有!),我们都需要您的信息!
  • 名字* 弗斯特 M.I。 最后
  • 电子邮件*

    别担心,我们不会向您发送垃圾邮件、共享或出售您的电子邮件地址

  • 地址*
  • 城市 陈述 拉链
  • 电话* - 地区 电话
  • 法律上的胡言乱语 别担心,你几乎完成了,这是我们需要你做的最后一点!
  • 官方规则* 1.若要输入,请通过提交此填写好的表单来完成联机请求。或者,寄一个贴好邮票、写好地址的信封到“蓝脊乡村啤酒节促销”,休闲出版公司,地址:弗吉尼亚州罗阿诺克市21535号邮政信箱,邮编:24018,索取报名表。每户限入一次。参赛作品必须在2009年6月30日前收到。2.预订程序随中标通知书一起提供。节假日和特殊活动期间不提供套餐。获奖通知将通过参赛表格上的电子邮件地址发送给获奖者。获胜的几率取决于参赛作品的数量。3.所有奖项将颁发给从收到的所有有效参赛作品中随机抽取的获奖者。抽奖将由独立出版商Leisure Publishing Inc.进行,该公司对与此次抽奖相关的所有事宜具有最终决定权。获奖者将通过电子邮件通知报名表上提供的地址。一个家庭或家庭只能获得一份奖品。由于本次比赛的性质,您必须年满21岁才能获胜。在收到与酒精相关活动的免费门票之前,需要提供年龄证明。4.除广告商、他们的员工、他们的广告和促销机构以及他们各自的家庭外,美国和加拿大的所有居民均可参加抽奖活动。法律征税、限制或禁止的地方无效。奖品不得转让;不得交换或替换;不能兑换现金;必须全面考虑这些问题;不允许替换。税收,如果有的话,是每个获奖者的责任。5.参加抽奖活动意味着允许将获奖者的姓名和照片用于广告和宣传目的,而无需对获奖者进行进一步补偿。有关获奖者的姓名,请将一个贴邮票、写好地址的信封寄至:“蓝岭国家啤酒节促销活动”-获奖者,地址:弗吉尼亚州罗阿诺克市邮政信箱21535,邮编:24018。
  • 订阅/赢取! 虽然您不必订阅win,但我们希望您能订阅!
  • 抽奖选择 机器人 猴子
  • 官方规则 我接受上述“官方规则”中的条款和条件。

不用等待你的编辑,我几乎可以保证问题出在你页面上的JS代码中,它正在将状态更改为你认为不一样的状态。我根本看不出这与CSS有关。我建议您检查DOM并遍历firebug中执行的方法

我敢打赌你的函数应该被重写:

function apply()
{
  with(document.form1) { sub.disabled = !chk.checked; }
}

这三个版本的HTML在FF3上都适用。需要更多信息-您正在使用哪个浏览器?什么是CSS?页面的其余部分是什么样的?您的功能没有什么意义-是否启用了您的扩展?如果没有,那么我建议进行重构。不相关,但您的document.form1.sub是否真的有一个已启用的属性,或者应该是read disabled=true?@annakata…我的问题也是@马蒂,你能多发一些吗?类名不应该根据您发布的内容更改任何内容,它甚至没有被引用。一些非常清晰是必要的。刚刚发布了整个页面,谢谢!
<input class="checkbox" type="checkbox" name="chk" onClick="apply()" value="accept" />
<?php
session_start();
if(!isset($_SESSION['referrer'])){
    //get the referrer
    if ($_SERVER['HTTP_REFERER']){
        $referrer = $_SERVER['HTTP_REFERER'];
    } else {
        $referrer = "unknown";
}
//save it in a session
$_SESSION[’referrer’] = $referrer; // store session data
}

//grab campaign var from url
$campaign = $_GET['campaign'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Beerfest Packages Sweepstakes - Blue Ridge Country</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="scripts/wufoo.js"></script>
<link rel="stylesheet" href="css/structure.css" type="text/css" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<link rel="stylesheet" href="css/theme.css" type="text/css" />
<script language=javascript>
function apply()
{
  document.form1.sub.disabled=true;
  if(document.form1.chk.checked==true)
  {
    document.form1.sub.disabled=false;
  }
  if(document.form1.chk.checked==false)
  {
    document.form1.sub.enabled=false;
  }
}
</script>  
</head>

<body id="public">

<img id="top" src="images/top.png" alt="" />
<div id="container">

<h1><a href="">Wufoo</a></h1>

<form class="wufoo" action="insert.php" method="post" name="form1">

    <div class="info">
        <h2>Register to Win &amp; Subscribe to Blue Ridge Country</h2>
        <div>Now's your chance to not only register to win our free beerfest tickets and getaway, but also receive the #1 magazine in the Blue Ridge Mountains!</div>
    </div>

    <ul>

    <li class="section first">
        <h3>Your information</h3>
        <div>Whether you're registering to win or subscribing to the magazine (or both!) we need your info!</div>
    </li>

    <li>
    <label class="desc">Name <span class="req">*</span></label>
        <span>
        <input class="field text" size="8" value=""/>
        <label>First</label>
        </span>

        <span>
        <input class="field text" size="3" value=""/>
        <label>M.I.</label>
        </span>

        <span>
        <input class="field text" size="14" value=""/>
        <label>Last</label>
        </span>
    </li>
    <li>
    <label class="desc">Email <span class="req">*</span></label>
        <div>
        <input class="field text medium" type="text" name="email" maxlength="100" value="" /> 
        </div>
        <p class="instruct">Don't worry, we won't spam you, share or sell your email address!</p>
    </li>    
    <li>
    <label class="desc">Address <span class="req">*</span></label>
        <div>
        <input class="field text medium" type="text" maxlength="100" value="" /> 
        </div>
    </li>
    <li>
        <span>
        <input class="field text" size="15" value="" />
        <label>City</label>
        </span>

        <span>
        <input class="field text" size="2" value="" />
        <label>State</label>
        </span>

        <span>
        <input class="field text" size="5" maxlength="10" value="" />
        <label>Zip</label>
        </span>
    </li>

    <li>
    <label class="desc">Phone <span class="req">*</span></label>
        <span>
        <input class="field text" type="text" size="3" maxlength="3" value=""/> - 
        <label>Area</label>
        </span>

        <span>
        <input class="field text" type="text" size="8" maxlength="8" value=""/>
        <label>Phone</label>
        </span>
    </li>    

    <li class="section">
        <h3>Legal mumbo jumbo</h3>
        <div>Don't worry, you're almost done and this is the last bit we need from you!</div>
    </li>

    <li>
    <label class="desc">Official Rules <span class="req">*</span></label>
        <div>
        <textarea rows="10" cols="50" class="field textarea medium" readonly="readonly" style="font-size: 0.8em;">1. To enter, complete an online request by submitting this completed form. Or, send a stamped, self-addressed envelope to: "Blue Ridge Country Beerfest Promotion," Leisure Publishing, PO Box 21535, Roanoke, VA 24018, requesting an entry form. Limited to one entry per household. Entries must be received by June 30, 2009. 2. Reservation procedures to come with notification of winning. Package not available during holidays and special events. Notification of prizes will be sent to winners at the email address on the entry form. The odds of winning will depend upon the number of entries. 3. All prizes will be awarded to winners selected by random drawing from all valid entries received. Drawing will be conducted by Leisure Publishing Inc., an independent publisher, whose decisions are final on all matters relating to this sweepstakes. Winners will be notified by email to the address provided on the entry form. Only one prize to a family or household. Due to the nature of this competition, you must be 21 or older to win. Proof of age will be required prior to receiving free tickets to alcohol-related events. 4. Sweepstakes is open to all residents of the U.S. and Canada except advertisers, their employees, their advertising and promotion agencies, and the families of each. Void wherever taxed, restricted or prohibited by law. Prizes are not transferable; may not be exchanged or substituted; cannot be redeemed for cash; must be taken in their entirety; no substitutions permitted. Taxes, if any, are the responsibility of the individual winners. 5. Entry in sweepstakes constitutes permission to use winners’ names and photograph for advertising and publicity purposes, without further compensation to winners. For names of prize winners, send a stamped, self-addressed envelope to: "Blue Ridge Country Beerfest Promotion" — Winners, P.O. Box 21535, Roanoke, VA 24018.</textarea>
        </div>
    </li>

    <li class="section">
        <h3>Subscribe / Win!</h3>
        <div>While you don't have to subscribe to win, we hope you will!</div>
    </li>

    <li>
    <label class="desc">Sweepstakes Selection</label>
        <div class="col">
        <span><input id="choice1" name="mc" class="field radio" type="radio" value="Robots" checked="checked" />
        <label class="choice" for="choice1">Robots</label></span>

        <span><input id="choice2" name="mc" class="field radio" type="radio" value="Monkeys"/>
        <label class="choice" for="choice2">Monkeys</label></span>
        </div>
    </li>

    <li>
    <label class="desc">Official Rules</label>
        <div class="col">
        <span><input class="checkbox" type="checkbox" name="chk" onClick="apply()" value="accept" />
        <label class="choice">I accept the terms and conditions from the "Official Rules" above.</label></span>
        </div>
    </li>    

    <li class="buttons">
        <input id="saveForm" class="btTxt" type="submit" name="sub" value="Submit" disabled="disabled" />
    </li>
    </ul>

    <div style="display: none;">
        <input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
        <input type="hidden" name="campaignID" value="<?php echo $campaign; ?>" />
    </div>

</form>

</div>
function apply()
{
  with(document.form1) { sub.disabled = !chk.checked; }
}