在 Dreamwever CS5 中选择另一个按钮时,单选按钮不会取消选择

发布于 2024-12-15 12:15:37 字数 4785 浏览 1 评论 0原文

在此处输入链接说明在此处输入代码 我的问题是单选按钮一旦选择就不会取消选择。该表单连接到我为作业构建的 php 文件。在 Dreamweaver 中,如果我保留 name 属性的默认值,则按钮不会出现问题,但由于 name 属性的值必须与 php 文件中的 name 属性匹配,所以我无法保留默认名称。我尝试过使用组按钮和单个按钮并复制它们。在文本页面中,当选择另一个按钮时,我能够取消选择按钮。然后它停止工作,所有按钮都保持选中状态。我很困惑,因为我认为单选按钮包含布尔值,当选择一个时,另一个会被取消选择。有什么建议吗?这是代码

 <!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>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>Homework 7</title>
 <script type="text/javascript">
 function edits()
 {
 if(document.getElementById("name").value=="")
 {
alert("Please enter your whole name.")
return false;
 }
if(document.getElementById("jarreau").checked=="")
 {
alert("Please enter your whole name.")
return false;
 }
else if(document.getElementById("aretha").checked=="")
 {
alert("Please enter your whole name.")
return false;
 }
else if(document.getElementById("withers").checked=="")
 {
alert("Please enter your whole name.")
return false;
}
else if(document.getElementById("joel").checked=="")
 {
alert("Please enter your whole name.")
return false;
}
else if(document.getElementById("warwidk").checked=="")
{
alert("Please enter your whole name.")
return false;
}
if(document.getElementById("rate").value=="")
{
alert("Please enter your whole name.")
return false;

if(document.getElementById("email").value=="")
{
alert("Please enter your whole name.")
return false;
 }
}
else return true;
}

 </script>
 <style type="text/css">
 body {
background-color: #F9F; 
 }
 h1 {
font-size: xx-large;
color: #FFF;
 }
 </style>
 </head>

 <body>
 <h1 font color="#fff">Old School Concert</h1>
 <table width="87%" border="0" cellspacing="0" cellpadding="2">
 <tr>
 <th align="left" width="19%" scope="col">Al Jarreau</th>
 <th align="left"width="13%" scope="col">Aretha Franklin</th>
  <th align="left"width="16%" scope="col">Bill Withers</th>
 <th align="left"width="19%" scope="col">Billy Joel</th>
 <th align="left"width="19%" scope="col">Dionne Warwick</th>
</tr>
<tr>
<td><img src="al jarreau.jpg" width="247" height="204" alt="Al Jarreau" /></td>
<td><img src="images/aretha franklin.jpg" width="198" height="204" alt="aretha franklin" /></td>
<td><img src="Bill Withers.jpg" width="192" height="204" alt="Bill Withers" /></td>
<td><img src="billy joel.jpg" width="225" height="204" alt="Billy Joel" /></td>
<td><img src="Dionne Warwick.jpg" width="176" height="204" alt="Dionne Warwick" /></td>
</tr>

为了不断为您带来最好的老派传奇,请填写这份简短的调查。

 <form name="service" method="post" action="concert.php" />
 <label for="fname">First name:</label>
<input name="name" type="text" id="fname" size="20" maxlength="15" />
(optional)
<br />
 <label for="lname">Last name:</label>
<input name="name" type="text" id="lname" size="20" maxlength="15" />
(optional)<br />
 <label>Which performance you liked best:</label><br />

 <p>
  <label>
    <input type="radio" name="jarreau" value="radio" id="RadioGroup1_0"/>
    Al Jarreau</label>
  <br />
  <label>
    <input type="radio" name="aretha" value="radio" id="RadioGroup1_1" />
    Aretha Franklin</label>
  <br />
  <label>
    <input type="radio" name="withers" value="radio" id="RadioGroup1_2" />
    Bill Withers</label>
  <br />
  <label>
    <input type="radio" name="joel" value="radio" id="RadioGroup1_3" />
    Billy Joel</label>
  <br />
  <label>
    <input type="radio" name="warwick" value="radio" id="RadioGroup1_4" />
    Dionne Warwick</label>

</p>

 <br />
 <label for="rate">On a scale of 1 to 10 how would you rate this concert?</label>
<br />
<input name="rate" type="text" id="rate" size="5" maxlength="2" />
 <label for="email"><br />
Your email address:</label>
  <br />
<input name="email" type="text" id="email" size="45" maxlength="45" />
</p>
 <p>
 <label for="comment">Your comments:</label>
<textarea name="comment" cols="50" rows="5" id="comment"></textarea>
</p>
<input type="button" value="submit" name="" id="" onclick="edits()" />
</form>
</body>
</html>

enter link description hereenter code here My problem is that the radio buttons won't deselect once selected. This form is connected to a php file that I build for my homework. In Dreamweaver if I keep the default value for the name attribute I don't have a problem with the buttons, but since the value of the name attribute has to match the name attribute in the php file I can't keep the default name. I've tried using group buttons and single buttons and copying them. In a text page I was able to get buttons to deselect when another button was selected. And then it stopped working, all the buttons stayed checked. I'm confused because I thought radio buttons contained boolean values, when one is selected the other is deselected. Any suggestions? Here is the code

 <!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>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>Homework 7</title>
 <script type="text/javascript">
 function edits()
 {
 if(document.getElementById("name").value=="")
 {
alert("Please enter your whole name.")
return false;
 }
if(document.getElementById("jarreau").checked=="")
 {
alert("Please enter your whole name.")
return false;
 }
else if(document.getElementById("aretha").checked=="")
 {
alert("Please enter your whole name.")
return false;
 }
else if(document.getElementById("withers").checked=="")
 {
alert("Please enter your whole name.")
return false;
}
else if(document.getElementById("joel").checked=="")
 {
alert("Please enter your whole name.")
return false;
}
else if(document.getElementById("warwidk").checked=="")
{
alert("Please enter your whole name.")
return false;
}
if(document.getElementById("rate").value=="")
{
alert("Please enter your whole name.")
return false;

if(document.getElementById("email").value=="")
{
alert("Please enter your whole name.")
return false;
 }
}
else return true;
}

 </script>
 <style type="text/css">
 body {
background-color: #F9F; 
 }
 h1 {
font-size: xx-large;
color: #FFF;
 }
 </style>
 </head>

 <body>
 <h1 font color="#fff">Old School Concert</h1>
 <table width="87%" border="0" cellspacing="0" cellpadding="2">
 <tr>
 <th align="left" width="19%" scope="col">Al Jarreau</th>
 <th align="left"width="13%" scope="col">Aretha Franklin</th>
  <th align="left"width="16%" scope="col">Bill Withers</th>
 <th align="left"width="19%" scope="col">Billy Joel</th>
 <th align="left"width="19%" scope="col">Dionne Warwick</th>
</tr>
<tr>
<td><img src="al jarreau.jpg" width="247" height="204" alt="Al Jarreau" /></td>
<td><img src="images/aretha franklin.jpg" width="198" height="204" alt="aretha franklin" /></td>
<td><img src="Bill Withers.jpg" width="192" height="204" alt="Bill Withers" /></td>
<td><img src="billy joel.jpg" width="225" height="204" alt="Billy Joel" /></td>
<td><img src="Dionne Warwick.jpg" width="176" height="204" alt="Dionne Warwick" /></td>
</tr>

In order to keep bringing you the best in old school legends please fill out this brief survey.

 <form name="service" method="post" action="concert.php" />
 <label for="fname">First name:</label>
<input name="name" type="text" id="fname" size="20" maxlength="15" />
(optional)
<br />
 <label for="lname">Last name:</label>
<input name="name" type="text" id="lname" size="20" maxlength="15" />
(optional)<br />
 <label>Which performance you liked best:</label><br />

 <p>
  <label>
    <input type="radio" name="jarreau" value="radio" id="RadioGroup1_0"/>
    Al Jarreau</label>
  <br />
  <label>
    <input type="radio" name="aretha" value="radio" id="RadioGroup1_1" />
    Aretha Franklin</label>
  <br />
  <label>
    <input type="radio" name="withers" value="radio" id="RadioGroup1_2" />
    Bill Withers</label>
  <br />
  <label>
    <input type="radio" name="joel" value="radio" id="RadioGroup1_3" />
    Billy Joel</label>
  <br />
  <label>
    <input type="radio" name="warwick" value="radio" id="RadioGroup1_4" />
    Dionne Warwick</label>

</p>

 <br />
 <label for="rate">On a scale of 1 to 10 how would you rate this concert?</label>
<br />
<input name="rate" type="text" id="rate" size="5" maxlength="2" />
 <label for="email"><br />
Your email address:</label>
  <br />
<input name="email" type="text" id="email" size="45" maxlength="45" />
</p>
 <p>
 <label for="comment">Your comments:</label>
<textarea name="comment" cols="50" rows="5" id="comment"></textarea>
</p>
<input type="button" value="submit" name="" id="" onclick="edits()" />
</form>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤芳又自赏 2024-12-22 12:15:37

您必须为所有单选按钮指定相同的“名称”,例如:

<input name="thesamegroup" type="button" value="submit"  id="" onclick="edits()" />
<input name="thesamegroup" type="text" id="email" size="45" maxlength="45" />

you have to give all the radio buttons the same "name" like:

<input name="thesamegroup" type="button" value="submit"  id="" onclick="edits()" />
<input name="thesamegroup" type="text" id="email" size="45" maxlength="45" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文