I have a form with a textbox and then another form with three textboxes. The text I enter in the first textbox (id="logoName") should be visible in the other three (ids v1 - v3) when i click the button. I tried the following, but when I click the button, the text in the first box disappers instead of showing in the others as well... what did I do wrong? Thanks a lot for your help!!!
JS
var logoName = document.getElementById("logoName");
var v1 = document.getElementById("v1");
var v2 = document.getElementById("v2");
var v3 = document.getElementById("v3");
var button = document.getElementById("button");
function sync() {
v1.value = logoName.value;
v2.value = logoName.value;
v3.value = logoName.value;
}
button.onclick = sync();
CSS
p {
font-size: 2em;
float: left;
margin-right: 2em;
}
.clear {
clear: both;
}
.overview {
margin-top: 2em;
}
input[type="text"] {
font-size: 2em;
width: 200px;
}
HTML
<form>
<label>Logo-Name</label>
<input id="logoName" type="text"/>
<button id="button">synchronise</button>
</form>
<form class="overview">
<input id="v1" type="text" /> <input id="v2" type="text" /> <input id="v3" type="text" />
</form>