js给文本框赋值.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">

  <script type="text/javascript">

  function getUri(){
             
  var uri='';
  alert(document.getElementById("Y").checked);
  if (document.getElementById("Y").checked){
                 uri=document.getElementById("Y").value; 
  }
  if (document.getElementById("M").checked){
if (uri==''){
   uri=uri+document.getElementById("M").value;
}else{
   uri=uri+"/"+document.getElementById("M").value;
}
  
      }
  if (document.getElementById("D").checked){
     if (uri==''){
   uri=uri+document.getElementById("D").value;
}else{
   uri=uri+"/"+document.getElementById("D").value;
}
      }
  document.getElementById("test").value=uri;
  }
</script>
</head>

<body>
        <input type="checkbox" id="Y" name="Y" value="YYYY" onclick="getUri()"/>年
<input type="checkbox" id="M" name="M" value="MM" onclick="getUri()"/> 月
<input type="checkbox" id="D" name="D" value="DD" onclick="getUri()"/> 日

        <input type="text" id="test" name="test"  >



<div style="background-color:#B5D5FB; width:300px; height:400px;"></div>
</body>
</html>

你可能感兴趣的:(html)