Now, I cannot get the textarea to submit upon someone pressing the enter button.
I've tried the code from this page: http://www.webdeveloper.com/forum/archive /index.php/t-52668.html
(pj59's post), but it didn't work.
I've tried putting the first half of the code in the index.lib.php, then in the input.php, but neither one worked.
the code I have:
first half:
<script language="JavaScript" type="text/javascript"> <!-- var isShift=null; var isNN = (navigator.appName.indexOf("Netscape")!=-1); var OP = (navigator.appName.indexOf("Opera")!=-1); if(OP)isNN=true; var key; function shift(event){ key = (isNN) ? event.which : event.keyCode; if (key==16)isShift=1; } function process(event){ key = (isNN) ? event.which : event.keyCode; if(document.layers&&event.modifiers==4){ isShift=1; } if (key==13&&isShift!=1){ document.MsgForm.submit(); } if (key!=16)isShift=null; } function retrieve(){ document.MsgForm.M.focus(); if(location.search.length>0){ blubb=unescape(location.search.split('=')[1]); } } //--> </script>
second part, integrated into the textarea:
<textarea NAME="M" onkeypress="process(event)" onkeydown="shift(event)" style="width:400px; height:35px; vertical-align: top; text-align: left" VALUE="<?php echo(htmlspecialchars(stripslashes($ValM))); ?>"<?php echo((isset($C) && $C != "") ? " style=\"color: $C;\"" : ""); ?>></textarea>
Obviously, I'm doing something wrong, but I'm completely clueless as to what.
So, I still haven't messed with it any in hopes of still getting some help.
First part should go in the header area of the same input.php and handle_input.php (for IE an FF). Did you try that?
I'm not sure if that code works as expected in the first place... let me make some tests myself.
It worked, but the correct code would be:
<script language="JavaScript" type="text/javascript"> <!-- var isShift=null; var isNN = (navigator.appName.indexOf("Netscape")!=-1); var OP = (navigator.appName.indexOf("Opera")!=-1); if(OP)isNN=true; var key; function shift(event){ key = (isNN) ? event.which : event.keyCode; if (key==16)isShift=1; } function process(event){ key = (isNN) ? event.which : event.keyCode; if(document.layers&&event.modifiers==4){ isShift=1; } if (key==13&&isShift!=1){ [b]document.forms['MsgForm'].submit();[/b] } if (key!=16)isShift=null; } function retrieve(){ [b]document.forms['MsgForm'].elements['M'].focus();[/b] if(location.search.length>0){ blubb=unescape(location.search.split('=')[1]); } } //--> </script>
Note the bold lines.
This javascript code is too long I guess and it can be stripped out. Like you don't need the retrieve function.
Note: try without adding it in handle_inputH.php - it should work in input.php only.
Hmm, I added it to input.php and handle_inputH.php
I tested it in Google Chrome first.
It did not work.
I decided to test it in IE and FF after that.
It worked in IE but not in FF.
Thank you for your help so far, though. It has helped me a bunch.
Actually, the submit on enter function started to work in Google Chrome. Mysterious, but nice.
Log in to post a comment.
Now, I cannot get the textarea to submit upon someone pressing the enter
button.
I've tried the code from this page: http://www.webdeveloper.com/forum/archive
/index.php/t-52668.html
(pj59's post), but it didn't work.
I've tried putting the first half of the code in the index.lib.php, then in
the input.php, but neither one worked.
the code I have:
first half:
second part, integrated into the textarea:
Obviously, I'm doing something wrong, but I'm completely clueless as to what.
So, I still haven't messed with it any in hopes of still getting some help.
First part should go in the header area of the same input.php and
handle_input.php (for IE an FF). Did you try that?
I'm not sure if that code works as expected in the first place... let me make
some tests myself.
It worked, but the correct code would be:
Note the bold lines.
This javascript code is too long I guess and it can be stripped out. Like you
don't need the retrieve function.
Note: try without adding it in handle_inputH.php - it should work in input.php
only.
Hmm, I added it to input.php and handle_inputH.php
I tested it in Google Chrome first.
It did not work.
I decided to test it in IE and FF after that.
It worked in IE but not in FF.
Thank you for your help so far, though. It has helped me a bunch.
Actually, the submit on enter function started to work in Google Chrome.
Mysterious, but nice.