Click to See Complete Forum and Search --> : no form submit
diamonds
05-31-2003, 04:17 PM
I know it is possable, but in a I do not (in other words: N - E - V - E - R) want the page to submit when the enter key is pressed. I've tried everything. but this (http://javascript.internet.com/buttons/click-to-submit.html) is the closest iv'e gotten. Any sugestions? additionally, I only want this to be true for when it only one spicific box is selected (the rest are scrolling text boxes). but if the first step is all you can do, fine by me :P, i'll do the rest.
-confused in the Sahara :confused:
diamonds
05-31-2003, 04:40 PM
this is the code, if anyone is intrested
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script>
function onKeyPress () {
var keycode;
if (window.event) keycode = window.event.keyCode;
if (keycode == 13) {
//add text function here
}
}
document.onkeypress = onKeyPress;
// End -->
</script>
</head>
<body>
<form>
<p><textarea rows="5" name="response" cols="20"></textarea><br>
<input type="text" name="type" size="26"></p>
<p>press enter to add text.</p>
</form>
</body>
</html>
diamonds
05-31-2003, 05:18 PM
totally COOL!
Yes, I dont mind if it dosen't work in netscape
oh, it clears the text box to! (somthing I wanted :) )
diamonds
05-31-2003, 06:28 PM
seeing all this return false; stuff, I wonder, can you return a variable?
<script>function return(){
return "one";
}
document.write(return();)
</script>
Or somthing like that?
brendandonhue
05-31-2003, 07:04 PM
If you want the enter key to NEVER and absolutely NEVER submit, you can't do it in javascript. 13% of users don't have JS enabled. And if it doesnt work in NS thats another 5% of users that will submit when the enter key is pressed.
diamonds
06-01-2003, 09:22 AM
Originally posted by brendandonhue
If you want the enter key to NEVER and absolutely NEVER submit, you can't do it in javascript. 13% of users don't have JS enabled. And if it doesnt work in NS thats another 5% of users that will submit when the enter key is pressed.
Well, actually, I only want the script to work in IE, and I only want it to take place in one little field.
and, if people don't have javascript and i didn't have the 'never submit' script, it wouldn't work anyway.