473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to catch keystroke of enter key pressed?

nirmalsingh
218 100+
hi all!

for example;[enter] represents pressing enter key.
i am typing "nirmal [enter] singh [enter] B"
in a text area, so the result in textarea will be in three lines as follows.

nirmal
singh
B

while i get this data from textarea and save in database, i want to save something representing like enter key pressed or new line along with text. so that i can retrieve the record from database and show it in a same format as

nirmal
singh
B

how can i do this?

thanx in advance.
Oct 12 '07 #1
8 2874
dmjpro
2,476 2GB
hi all!

for example;[enter] represents pressing enter key.
i am typing "nirmal [enter] singh [enter] B"
in a text area, so the result in textarea will be in three lines as follows.

nirmal
singh
B

while i get this data from textarea and save in database, i want to save something representing like enter key pressed or new line along with text. so that i can retrieve the record from database and show it in a same format as

nirmal
singh
B

how can i do this?

thanx in advance.
Now what's getting stored in DataBase?

Debasis Jana
Oct 12 '07 #2
nirmalsingh
218 100+
Now what's getting stored in DataBase?

Debasis Jana
while passing the value in query string using ajax to save it, the enter character is ignored and saved as a sequence sentence.
Oct 12 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

you may use a regEx to prepare the value ... have a look at the following example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. function prepare_value() {
  6.     var value = document.getElementById('text').value;
  7.  
  8.     value = value.replace(/(\n|\r\n)/g, '\n');
  9.  
  10.     alert(value);
  11. }
  12.  
  13. </script>
  14. </head>
  15. <body>
  16.     <form name="myform">
  17.         <textarea id="text"></textarea>
  18.         <input type="button" value="prepare" onclick="prepare_value();">
  19.     </form>
  20. </body>
  21. </html>
  22.  
kind regards
Oct 12 '07 #4
nirmalsingh
218 100+
hi ...

you may use a regEx to prepare the value ... have a look at the following example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. function prepare_value() {
  6.     var value = document.getElementById('text').value;
  7.  
  8.     value = value.replace(/(\n|\r\n)/g, '\n');
  9.  
  10.     alert(value);
  11. }
  12.  
  13. </script>
  14. </head>
  15. <body>
  16.     <form name="myform">
  17.         <textarea id="text"></textarea>
  18.         <input type="button" value="prepare" onclick="prepare_value();">
  19.     </form>
  20. </body>
  21. </html>
  22.  
kind regards
yah it is working well as i wished format, but when i transfer that data to another page via querystring, all the datas are concatenated as nirmalsinghb
what to do to solve this?
Oct 15 '07 #5
dmjpro
2,476 2GB
yah it is working well as i wished format, but when i transfer that data to another page via querystring, all the datas are concatenated as nirmalsinghb
what to do to solve this?
You can use a special character and then replace it using your server side script.
Mind it your special character should never occur in your Query String.

Debasis Jana
Oct 15 '07 #6
nirmalsingh
218 100+
You can use a special character and then replace it using your server side script.
Mind it your special character should never occur in your Query String.

Debasis Jana
thank u jana i already tried it.
but i replaced the character,'/n' by '~' but it is not replaced.
Oct 15 '07 #7
dmjpro
2,476 2GB
thank u jana i already tried it.
but i replaced the character,'/n' by '~' but it is not replaced.
Expand|Select|Wrap|Line Numbers
  1. var value = document.getElementById('text').value;
  2. value = value.replace(/(\n|\r\n)/g, '~');
  3. //now here prepare the query string ...............
  4.  

Debasis Jana
Oct 15 '07 #8
nirmalsingh
218 100+
Expand|Select|Wrap|Line Numbers
  1. var value = document.getElementById('text').value;
  2. value = value.replace(/(\n|\r\n)/g, '~');
  3. //now here prepare the query string ...............
  4.  

Debasis Jana
thanx jana, its working perfectly.
Oct 15 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Amin Gunawan via .NET 247 | last post by:
I would like to put a combo box in a column of a datagrid. I've seen the samples in the MSDN library of other sources, butall samples didn't catch the 'DOWN/UP' keystroke. It means thatwhen I select...
15
by: Frank Bormann | last post by:
Hi, probably a stupid question, but I haven't been able to find anything. Is there a istream related function that let me read exactly one keystroke from the keyboard through cin? What I...
3
by: GG | last post by:
I have a console app that when it is run and I press a key then it freezes till a press another key gain. Is there a way to avoid it that is the keystrokes do not pause the app? Thanks ...
3
by: Brian Schwartz | last post by:
I'm writing a console application. Both Read and ReadLine wait for enter to be pressed before returning. Isn't there a way to read a single character and continue immediately, without waiting for...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
1
by: tekhneek | last post by:
is there ANYWAY to have a variable monitor keystrokes on an active page with javascript and if x keys are pressed, show an alert? in other words If I'm on the site and I type in "login", it alerts...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
8
by: gsxg | last post by:
I am new to python, and have written a simple program to read a port via telnet. I would like it to run until any key is pressed. Of course I wouldn't mind requiring a specific keystroke in the...
1
by: visweswaran2830 | last post by:
Hi, I need to stop the keystroke event when I pressed a particular key. For Eg: If press alt+tab key then that keys should not perform that operation, that should operation should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.