Tuesday, 26 November 2013

Take Multiple values from user using Promt properties in JS

<!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>
    <title></title>
    <script type="text/javascript">
        function f1() {
            var num = document.getElementById("txtNum").value;
            var arr = new Array();
            var add=0;
            for (var i = 1; i <= num; i++) {
                var input = prompt("plz input value..");
                arr[i] = input;
                add = add + arr[i];
                alert(add);
            }
            alert("thank u..");
        }
        alert("HI");
       
    </script>
</head>
<body>
<input id="txtNum" type="text" placeholder="Enter no only.." />
<input id="btnNum" type="button" value="button" onclick="f1()" />
</body>


</html>

No comments:

Post a Comment