By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,337 Members | 2,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,337 IT Pros & Developers. It's quick & easy.

single text field, submission with ENTER or TAB

P: n/a
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>

Dec 19 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 19 '06 #2

P: n/a
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.

Dec 19 '06 #3

P: n/a
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]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.