faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 18 people (56%) answered Yes
Recently 7 of 10 people (70%) answered Yes


why ENTER KEY does not post a page when i querystring a page ...! but it works fine when i submit

Apr 7th, 2008 23:05
ha mo, Ky Dang, Jean-Bernard Valentaten, SK RK,

Well, it really depends on which method you use to submit the page and 
how you build your querystring.
If you use the GET method (e.g. <form action="..." method="GET" ...>), 
the browser will build a querystring that is escaped (URI-encoded that 
is), attaches the querystring to the webpages' name (separated by a 
question mark) and then calls that address (e.g. 
http://www.yourURL.com?p=1&n=2). Since a querystring is plaintext, 
some characters might not be transported very well or might get parsed 
out by the web-server, so they need to be URI-encoded. JavaScript 1.5 
has a method called encodeURI(), previous versions had a method called 
escape() to achieve that (you'll find plenty of information on bboth 
methods by searching the web *g*).
If you use the POST metjod (e.g. <form action="..." 
method="POST" ...>), the browser will open a special connection to the 
web-server and transmits the data through it (this works like a remote 
procedure call), so you won't be able to achieve that by using 
JavaScript (since js is not capable of controlling sockets).
Entry: November 10, 2004
Try to trap the enterKey (code=13) an call the submit for the form.   
(I have not tested this so let me know if it does not work for you.)
function enterKeyTrap()
  if (window.event.keyCode == 13)
<form name="myForm" onkeyup="enterKeyTrap();">
  <input type="submit" value="Go" name="B1">