2016年5月6日 星期五

5/6 加法 選項HTML

加法





<!DOCTYPE html >
<html >
<head>
   <title>加法運算器</title>
    <script>
        function add() {
            var a = parseInt(document.getElementById('a').value);
            var b = parseInt(document.getElementById('b').value);
            document.getElementById('result').value =  a+b ;
        }
    </script>
</head>
<body>
    <input id="a" type="text" />+<input id="b" type="text" />
    <button onclick="add()" >=</button>
    <output id="result"></output>
</body>
</html>












選項HTML

<html>

<head>
<title>Form</title>
<script>
function check1(){
var radio1=document.getElementsByName("v1");
var radio2=document.getElementsByName("v2");
   for(var i=0;i<radio1.length;i++){
         if(radio1.item(i).checked==true){
   
     var flag1 = radio1.item(i).value;            

       }
   }
    for(var j=0;j<radio2.length;j++){
         if(radio2.item(j).checked==true){
   
     var flag2 = radio2.item(j).value;        
       }
   }
   document.write("1、"+flag1+"2`"+flag2);
  }
</script>
</head>
<body>

<form action="post.php" method="post"  name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>1、ssss?</h1>
<input name="v1" type="radio" value="300年">300年            
<input name="v1" type="radio" value="400年">400年              
<input name="v1" type="radio" value="1000年">1000年
</form>

<form action="post.php" method="post"  name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>2、ssss?</h1>
<input name="v2" type="radio" value="300年">300        
<input name="v2" type="radio" value="400年">400          
<input name="v2" type="radio" value="1000年">600
<input type="button" value="submit" onclick="check1()"/>
</form>

</body>
</html>

沒有留言:

張貼留言