CppBuzz.com
  
Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Forum » x-Forum » Question

JavaScript code to get value of popup

Please share JavaScript code which popups and ask user to enter his name then it prints its value

Posted by Admin 2018-09-26 21:29:36

<html>
<head>
</head>
<script>
         
function myFun(){

              var name=prompt("enter the name");
              if(name!="NULL")
                    {
                               
                 document.getElementById("demo").innerHTML =
           "Hello "+name;
                     }

                    }

</script>

<body>
<p id="demo">
<button   onclick="myFun()">Click</button></p>
</body>


</html>

C++ user image Gowthami posted 2018-09-27 23:05:42

Gowthami, Thank you for posting answer. It works fine.

C++ user image Admin posted 2018-10-01 07:49:56

Thank you sir.

C++ user image Gowthami posted 2018-10-12 02:48:31

Thanks for your valuable comment sir

C++ user image Gowthami posted 2018-10-12 02:49:46

Your Answer


Ask New Question