如何使用javascript onclick函數連續輸入密碼值到密碼字段?使用onclick函數將JavaScript值連續輸入到密碼輸入中?
我有兩個'藍'和'紅'的圖像與onclick函數一起使用,並具有下面的值;
Blue= w3!
Red= T4.
當我點擊藍色圖像時,輸入值'w3!'進入密碼字段。但是當我點擊紅色圖像時,它將替換輸入並在密碼字段中變爲'T4'。如何在密碼字段中將紅色輸入與藍色相連以變爲'w3!T4',而不是替換它?請幫我在這裏...... thx。 下面是我的代碼條目:
<!DOCTYPE html>
<html>
<head>
<style>
# red
{width:50px;
height:50px;
}
# blue
{width:50px;
height:50px;
}
</style>
<script src="javascript/myred.js"></script>
<script src="javascript/myblue.js"></script>
</head>
<body>
<img id="red" src="images/items/blue_in.jpg" alt="no blue" onclick="myblue()">
<img id="blue" src="images/items/red_in.jpg" alt="no red" onclick="myred()">
<label for="password">Passcode:</label>
<input name="password" type="password" id="password">
</body>
</html>
存儲在我的服務器
我的JavaScript文件如下圖所示;
對於myblue:
function myblue()
{
x=document.getElementById("password"); // Find the element
x.value="w3!"; // add the content
}
對於myred:
function myred()
{
x=document.getElementById("password"); // Find the element
x.value="T4"; // add the content
}
請,我怎麼可以添加藍色圖像的值到密碼字段,無需更換紅色輸入...乾杯。 。評論歡迎..
我感覺一些bruteforce web工具在做? –
不是真的,但做類似的研究... –
有沒有jQuery代碼,只是普通的Javascript,刪除該標籤。 – Barmar