0
入力値をデフォルト値で埋める塗りつぶしボタンを作成しようとしています。塗りつぶしボタンをクリックすると、デフォルトが2秒間表示されてから消えます。どのように私は情報をそれ自体をクリアすることなく滞在することができます。なぜonclickイベントの直後に入力ボックスがクリアされる
var enter, replace, FirstName, Telephone, email, BithDate, LastName, ZipCode, SS, Cash;
window.onload = function() {
//calls the functions when buttons clicked
replace = document.getElementById("fill");
replace.addEventListener("click", filler);
enter = document.getElementById("enter");
enter.addEventListener("click", calculate);
var clear = document.getElementById("clear");
clear.addEventListener("click", clear);
}
function filler() {
//list the default values to fill when the fill button is clicked
FirstName = document.getElementById("FirstName").value = "Jane";
Telephone = document.getElementById("tel").value = "888-777-9999";
email = document.getElementById("email").value = "[email protected]";
BithDate = document.getElementById("birth").value = "2017";
LastName = document.getElementById("LastName").value = "Doe";
ZipCode = document.getElementById("zip").value = "12345";
SS = document.getElementById("SocSec").value = "123-45-6789";
Cash = document.getElementById("income").value = "123456";
}
function clear() {
//clears the form and resets it to the default
document.getElementById("form").reset();
}
plunkerやjsfiddleなどの場所にサンプルを投稿すると、htmlを追加してください。 – Ivan
'filler()'関数が機能していますか?変数宣言が間違っていました** '' message ":"キャッチされていないTypeError:nullのプロパティ 'value'を設定できません "、** ** – prasanth
また計算機能がありません。 HTMLを投稿することも役に立ちます。 –