[英]How do I input password by clicking image with onclick function?
I need to enter-in a password (without typing on keyboard) by clicking on image(s) on my html page with onclick function or any other action. 我需要使用onclick功能或任何其他操作通过单击html页面上的图像来输入密码(无需在键盘上输入)。 How can I do this?
我怎样才能做到这一点? I tried the code below, which worked for plain text by didn't work for my password-type entry (as seen below).
我尝试了下面的代码,该代码不适用于我的密码类型输入(如下所示),无法用于纯文本。 Can someone pls help me?
有人可以帮我吗?
Here are my codes: 这是我的代码:
<form style=" margin-left:200px; font-weight:600">
<fieldset>
<legend>STEP II:</legend>
<input id="psx2" type="password">
<p id="psx3">all the way</p>
<p id="psx4">the ramp flies</p>
<script>
function myFunction()
{
x=document.getElementById("psx2"); // Find the element
x.innerHTML="12345"; // Change the content
x=document.getElementById("psx3"); // Find the element
x.innerHTML="Hello!"; // Change the content
x=document.getElementById("psx4"); // Find the element
x.innerHTML="Hey!"; // Change the content
}
</script>
<a href="#">
<img src="images/colourimages/red.jpg"
alt="red not"
onclick="myFunction()"
width="50"
height="50"
id="red" />
</a>
</fieldset>
</form>
This is the result: 结果如下:
you will notice that nothing showed on the password field. 您会注意到密码字段上没有任何显示。 Please can someone help?
请有人帮忙吗? I will appreciate it..
我将不胜感激..
表单元素不使用.innerHTML
来更改需要使用.value
的内容
Use value
for input elements
like, 将
value
用于input elements
例如,
function myFunction()
{
x=document.getElementById("psx2"); // Input element
x.value="12345"; // Change the content
// innerHTMl is fine for p or div tags
.......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.