fernandop
05-06-2009, 04:13 AM
Hello, friends!
I'm having some issues with my HTML/Javascript page. This is my code:
<script language="JavaScript">
function testaResultado (form) {
var resposta = form.txtResposta.value;
if (resposta.toUpperCase() == "GOOGLE") {
window.location = "pagina.html"
}
form.txtResposta.value= ""
}
function checaEnter (e, form) {
if ((e.which) == 13) {
testaResultado(form);
}
}
<form name="frmJogo" method="post">
<input type="text" name="txtResposta" onKeyPress="return checaEnter(event, this.form)"> <p>
<input type="button" name="btnOK" value="OK" onClick="testaResultado(this.form)">
</form>
When I type "google" on txtResposta (text object) and click on btnOK button, the pagina.html page is showed, ok. But if I press the [ENTER] key instead of clicking on btnOK button, the page is reloaded and pagina.html is not showed.
Can I do it? Where is the mistake?
Best regards,
Fernando
I'm having some issues with my HTML/Javascript page. This is my code:
<script language="JavaScript">
function testaResultado (form) {
var resposta = form.txtResposta.value;
if (resposta.toUpperCase() == "GOOGLE") {
window.location = "pagina.html"
}
form.txtResposta.value= ""
}
function checaEnter (e, form) {
if ((e.which) == 13) {
testaResultado(form);
}
}
<form name="frmJogo" method="post">
<input type="text" name="txtResposta" onKeyPress="return checaEnter(event, this.form)"> <p>
<input type="button" name="btnOK" value="OK" onClick="testaResultado(this.form)">
</form>
When I type "google" on txtResposta (text object) and click on btnOK button, the pagina.html page is showed, ok. But if I press the [ENTER] key instead of clicking on btnOK button, the page is reloaded and pagina.html is not showed.
Can I do it? Where is the mistake?
Best regards,
Fernando