<script>
function myinput()
{
myvalue=prompt("pls enter a value:");
alert(myvalue);
}
</script>
<input type=button onclick=myinput()>

解决方案 »

  1.   

    <html>
    <body>
    <input type=button value="Enter Value" onclick="myinput();" >
    </body><script language="javascript">
    function myinput()
    {
    var input=prompt("Please enter a value:");
    //be careful, whatever user input, javascript will treat it as a
    //"string", if you need a number, you need to use "parseInt()"
    //method to change String to Number. like the following:
    //var b=parseInt(input) +1;
    //alert(b);
    alert("You just entered: " + input);
    }
    </script>
    </html>