close

Javascript

教學網址: 加法

單選題

Java程式教學甘仔店:JavaScrupt教學目錄

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<h2>document.write用法</h2>
<Script type ="text/javascript">
document.write("Hello world!!");
</Script>
</body>
</html>

001.png

002.png

003.png

 

新增按鈕

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<h2>document.write用法</h2>
 <Script type ="text/javascript">

  function myFunInput(obj){
   obj
   alert("你的id編號為:"+obj.id);
  }

  document.write("Hello world!!");
 </Script>
<input type="button" value="請點擊" id="myId" onClick="myFunInput(this)">
</body>
</html>

004.png

單選題:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<form action="#" method="post" class="demoForm" id="demoForm">
    <fieldset>
        <legend>Demo: Get Value of Selected</legend>
    
    <p>Select a shipping method:</p>
    <p>
        <label><input type="radio" name="ship" value="a" checked />a. Standard Ground</label>
        <label><input type="radio" name="ship" value="b" />b. Second Day</label>
        <label><input type="radio" name="ship" value="c" />c. Overnight</label>
        <label><input type="radio" name="ship" value="d" />d. Pick up</label>
    </p>
    

        <p><button type="button" name="getVal">Get Value of Selected</button></p>


    </fieldset>
</form>

 <Script type ="text/javascript">
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-39542975-1', 'dyn-web.com');
  ga('send', 'pageview');
</script>            

<script type="text/javascript">
// to remove from global namespace
(function() {
    
    function getRadioVal(form, name) {
        var val;
        var radios = form.elements[name];
        
        for (var i=0, len=radios.length; i<len; i++) {
            if ( radios[i].checked ) {
                val = radios[i].value;
                break;
            }
        }
        return val;
    }


    document.forms['demoForm'].elements['getVal'].onclick = function() {
        alert( 'The selected radio button\'s value is: ' + getRadioVal(this.form, 'ship') );
    };
    
    
    // disable submission of all forms on this page
    for (var i=0, len=document.forms.length; i<len; i++) {
        document.forms[i].onsubmit = function() { return false; };
    }
    
}());
 </Script>

</body>
</html>

005.png

arrow
arrow
    全站熱搜

    D0389097 發表在 痞客邦 留言(0) 人氣()