English 中文(简体)
待装 内容 a 无
原标题:onload call to getElementById returns null

我在这里看一看一看一看一看,前面的很多答复都等待上载,要求得到执行。 顺便说一句,我开始做些什么,做的是做什么? 我的指数显示,根据《刑法》规定,收益无效。 php file:

<html>
<script type="text/javascript">

    function checkPwd()
    {
        var thePwd = document.getElementById("theUsersPassword");
        alert("the var thePwd is: " + thePwd);

    }
</script>        
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Beta:</title>
</head>

<body onload="checkPwd()">

  <form method="post"  action="index.php">
    Beta: <input name="theUsersPassword" type="password"><br/>
    <input type="submit" value="Submit" />  
    </form>

</body>
</html>
最佳回答

抵达 内容 a Id通过ID而不是姓名获得一个元素。 改变

<input name="theUsersPassword" type="password">

纽约总部

<input name="theUsersPassword" id="theUsersPassword" type="password" />
问题回答

页: 1

<><>Edit>:

换言之,你需要改变

<input name="theUsersPassword" type="password">

纽约总部

<input name="theUsersPassword" id="theUsersPassword" type="password">

You can use the code below. getElementById returned an object not a value.

Java

function checkPwd()
{
    var thePwd = document.getElementById("theUsersPassword").value;
    alert("the var thePwd is: " + thePwd);

}

Html

<input name="theUsersPassword"  id="theUsersPassword"  type="password">




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签