得到的checkbox的value不知道从哪儿出来的/?解决思路

WBOY
Release: 2016-06-13 13:35:55
Original
903 people have browsed it

得到的checkbox的value不知道从哪儿出来的/?
我从数据库里面获得了result,把roomname字段作为了checkbox的value,在javascript脚本的summitdata函数和mcustom.php中的得到的数据中间怎么都加了/?
1.
echo "

";
echo "";
while($row=mysql_fetch_array($result))
{
  echo "";
  echo "";
  echo "";//此处没有/
  echo "";  

echo "";
echo "
" . $row['roomname'] . "
";
echo "
";
2.javascript部分
function checkchecked(checkboxs)
{

  for(var i=0;i   {
  if(checkboxs[i].checked)  
  {
  alert(checkboxs[i].value);//此处得到的checkboxs[i].value的值101/,已经被加了/
  return true;
  }
   
  }
  alert("Please select the room.");
  return false;
}
function submitdata()
{
  var checkboxs=document.getElementsByName("selectrooms[]");
  var checked=checkchecked(checkboxs);
  if(checked)
  {
  var form=document.getElementById("roomlist");
  form.submit();
  }
  else
  {
  return false;
  }
}
3.mcustom.php中得到的
  if(isset($_GET["selectrooms"]))
  {
  $selectrooms=$_GET["selectrooms"];
  foreach($selectrooms as $item)
  {
  echo "";
  echo "" .$item . "";//此处也有/
  echo "";
  }
  }

------解决方案--------------------
value=" . $row['roomname'] . "/>";得出的结果大概是 value=roomnamevalue/>
value和/>之间没有空格,所以浏览器认为value=roomnamevalue/ 。建议在任何属性都加上""包含属性值
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!