473,503 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

text field to window URL (javascript)

1 New Member
Hello,
I've been trying to work on this all day, maybe someone here can give me a hand.

I need a simple (or so i think) javascript that will the user a text field.

The information that they enter (for ex. "cat") will actually lead them to a webpage cat.html within the same directory.

For example, The user types "cat" into the text field and hits enter. The browser then loads "cat.html"

I would like to do this without a "submit" button however i am not sure if that is possible to just allow a return key.


Thank you in advance
Paul
Sep 22 '06 #1
3 3658
ronverdonk
4,258 Recognized Expert Specialist
This is a sample of doing it without a submit button. Just hit enter.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <title>Some title</title>
  3. <head>
  4. <script type="text/javascript" language="javascript"> 
  5. function getEnter(evt) {
  6. evt = (evt) ? evt : event;
  7. var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? avt.which : evt.keyCode);
  8. if (charCode == 13  ||  charCode == 3)
  9.    location.href = document.myform.pass.value + '.html';
  10. else
  11.    return true;
  12. }
  13. </script>
  14. </head>
  15. <body>
  16. <form name="myform" onsubmit="return false">
  17.   Enter the name of the HTML file and hit ENTER: 
  18.   <input type="text" id="pass" name="pass" onkeypress="return getEnter(event)" />
  19. </form>
  20. </body>
  21. </html>
Ronald :cool:
Sep 22 '06 #2
internetstarter
2 New Member
Is there a way to embedd a url into the javascript?

Also how would I go about adding a submit button? the return to submit doesn't seem to work in firefox.

Thanks!
Oct 21 '06 #3
internetstarter
2 New Member
Is there a way to embedd a url into the javascript?

Also how would I go about adding a submit button? the return to submit doesn't seem to work in firefox.

Thanks!

This is a sample of doing it without a submit button. Just hit enter.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <title>Some title</title>
  3. <head>
  4. <script type="text/javascript" language="javascript"> 
  5. function getEnter(evt) {
  6. evt = (evt) ? evt : event;
  7. var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? avt.which : evt.keyCode);
  8. if (charCode == 13  ||  charCode == 3)
  9.    location.href = document.myform.pass.value + '.html';
  10. else
  11.    return true;
  12. }
  13. </script>
  14. </head>
  15. <body>
  16. <form name="myform" onsubmit="return false">
  17.   Enter the name of the HTML file and hit ENTER: 
  18.   <input type="text" id="pass" name="pass" onkeypress="return getEnter(event)" />
  19. </form>
  20. </body>
  21. </html>
Ronald :cool:
Nov 9 '06 #4

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

Similar topics

5
4690
by: Mike | last post by:
I'm using a script provided by e-mailanywhere, it's a little too big for me. There's 1 text field and 1 password field in a form. OnSubmit, I would like both fields to be validated to look for...
3
2882
by: Treetop | last post by:
I would like to pass text to a popup window to save creating a new html file for each help topic. I would like to have a value for the heading, a value for the text, code for printing the help...
2
2194
by: johkar | last post by:
Would there ever be any problems with the following script depending on what type of characters are in the text string? I am appending the value of hidden form field to the query string. ...
4
2580
by: Old Lady | last post by:
Hi, I need help! I have a SELECT/OPTION list. My goal is to have a TEXT input field in a form that is normally disabled, but it should become enabled when the user select one predefined OPTION....
5
2972
by: simon_s_li | last post by:
Hi, I have 5 fields in line where I need to drag and drop the text from one field to another field and then all the fields need to re-order themselves. So for instance if I drag the text in...
3
3183
by: excel_hari | last post by:
Hi, I couldnt locate a Classic ASP group hence posting here. One of my colleagues has designed an intranet site and one of the pages has a drop-down box with close to 300 options. I want to...
1
2309
by: divya | last post by:
I have a form which has a textarea,name - txtTo where he adds email addresses.Now when he clicks on sendemail I want to open a mailto link with addresses taken from textarea. Example I added...
4
4637
by: sufian | last post by:
Below is the field where user enters his/her email address and the AJAX post request is sent to the server and the user sees the message: echo("<div id=\"message\" class=\"success\">Thank you! You...
8
8689
by: sneddo | last post by:
Ok I am trying to do the above, I have got a script that will restrict the length but it requires the user to enter the field and hit a key, before it will work. This would normaly be find, but...
1
1390
by: anonymousstar | last post by:
Hi Everyone, I am creating a search facility that holds titles and SKU numbers. When the results appear in a 2 column table I would like the title to go into an input (readonly) field and the SKU...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.