Reputation: 49
alright, I have made a function to clear two text boxes on the click of a button. For some reason that I dont know it isnt working. Code is pasted below -
function clear() {
document.getElementById("IMEI").value = "";
document.getElementById("Command").value = "";
}
<!-- IMEI -->
<label><font color=#829DBA face="Tahoma"><b>IMEI:</b></font></label>
<input type="text" name="ID" id="IMEI" maxlength="15">
<!-- -->
<!-- AT Command -->
<label><font color=#829DBA face="Tahoma"><b>AT Command:</b></font></label>
<input id="Command" type="text">
<!-- -->
<!-- Clear Button -->
<button type="button" onclick="clear();">Clear</button>
<!-- -->
Thanks
Upvotes: 0
Views: 50
Reputation: 98
At the font-tag is a bug: color attribute needs quotes.
function clear() {
document.getElementById("IMEI").value = "";
document.getElementById("Command").value = "";
}
<!-- IMEI -->
<label><font color="#829DBA" face="Tahoma"><b>IMEI:</b></font></label>
<input type="text" name="ID" id="IMEI" maxlength="15">
<!-- -->
<!-- AT Command -->
<label><font color="#829DBA" face="Tahoma"><b>AT Command:</b></font></label>
<input id="Command" type="text">
<!-- -->
<!-- Clear Button -->
<button type="button" onclick="clear();">Clear</button>
<!-- -->
Upvotes: 0
Reputation: 4209
It's a scoping issue with the word clear
, change the function name to cleared
and you will see it working correctly. You could also call the function with window.clear()
if you were unable to rename this function for some reason.
Upvotes: 2