开发者

Creating Javascript function called ReadName()

I want to create a form which has a text entry box where a user 开发者_Python百科can enter their name and then I want a button as well. But what I want this button to have a function called ReadName() where what will happen is when the user clicks on the button it will come up with a message saying "Hello user name will appear here I have tried my self and but I don't think I am not getting what I want. Any help will be appreciated.

<form>
    <label for="name">Name:</label>
    <input type="text" name="name" id="name"/>
    <input type="text" name="name" onfocus="ReadName()"/>
</form>


function ReadName() {
    var name = document.getElementById('name').value;
    alert('Hello '+ name);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜