single text field, submission with ENTER or TAB

R

Rupe

Because this is a form with a single text field, I require submition
when ENTER OR TAB is pressed in the text box). However since their is
only one field I can't use tab. Nor for some reason can I use enter.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>third page</title>
<script type="text/javascript">
<!--
function changeEvent(){
alert("stuff");
document.close()
}
//-->
</script>
</head>

<body>
<form onsubmit="return false">
Enter text to be copied to calling page
<input type="text" onchange="changeEvent()" value="type something">
</form>
</body>
</html>
 
E

Evertjan.

Rupe wrote on 19 dec 2006 in comp.lang.javascript:
Because this is a form with a single text field, I require submition
when ENTER OR TAB is pressed in the text box). However since their is
only one field I can't use tab. Nor for some reason can I use enter.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>third page</title>
<script type="text/javascript">
<!--

do not use <!--

function changeEvent(){
alert("stuff");
document.close()
}
//-->

do not use //-->
</script>
</head>

<body>
<form onsubmit="return false">

Logically, my dear Watson, submission is effectively switched off by the
above onsubmit!
Enter text to be copied to calling page
<input type="text" onchange="changeEvent()" value="type something">

onchange will only fire on blur, I think.
</form>
</body>
</html>

Try:

<form>
<input
onkeydown = 'if (event.keyCode==9) this.form.submit();'
type="text" name='what' value="give enter or tab">
</form>
 
R

Rupe

i'm not actually wanting to do a submit as such, i'm only wanting to
update the main page data via opening a second page, placing details in
that second page then returning to the main page.

further, I was trying not to use window.open() rather just change the
location.href value. unfortunately just doing this on returning to the
main page, the second page's details remains in the browser. id running
window.document.title after returning to the main page returns the
title of the second page.

perhaps there a page naviagation tutorial online you recommend. as the
only way seems to be to open a second tab/window and then close it
after. I was just hoping to flick documents within the same tab.
 
E

Evertjan.

Rupe wrote on 19 dec 2006 in comp.lang.javascript:
i'm not actually wanting to do a submit as such,

What are you talking about???????

[please always quote on usenet]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top