samedi 12 novembre 2016

Can't get this form to work on HTML5

sorry for what might be a noob question.. I've been fiddling with this form for some time now but I can't seem to make it work for some reason. The colour changes work but the submit button simply does not lead to the link..

<center>
<form name="form1" method="POST">
<input id="codebox1" type="text" onchange="checkFilled1();" />
<input id="codebox2" type="text" onchange="checkFilled2();" />
<input id="codebox3" type="text" onchange="checkFilled3();" />
<br>
<br>
<input id="button1" type="submit" value="Submit" onClick="testResults(this.form)" />
</form>
</center>

And here are the functions:

<script>
function checkFilled1() {
var inputVal = document.getElementById("codebox1");
if (inputVal.value == "1234") {
inputVal.style.backgroundColor = "lightgreen";
} else {
inputVal.style.backgroundColor = "red";
}
}

checkFilled1();
</script>

<script>
function checkFilled2() {
var inputVal = document.getElementById("codebox2");
if (inputVal.value == "1234") {
inputVal.style.backgroundColor = "lightgreen";
} else {
inputVal.style.backgroundColor = "red";
}
}

checkFilled2();
</script>

<script>
function checkFilled3() {
var inputVal = document.getElementById("codebox3");
if (inputVal.value == "1234") {
inputVal.style.backgroundColor = "lightgreen";
} else {
inputVal.style.backgroundColor = "red";
}
}

checkFilled3();
</script>

<script>
function testResults() {
var inputVal1 = document.getElementById("codebox1");
var inputVal2 = document.getElementById("codebox2");
var inputVal3 = document.getElementById("codebox3");
if (inputVal1.value == "1234") && (inputVal2.value == "1234") && (inputVal3.value == "1234") {
window.open("http://google.com", "_parent");
} else {

}
}

testResults();
</script>

Thanks for the help!

Aucun commentaire:

Enregistrer un commentaire