473,651 Members | 3,012 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 3663
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
4697
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 invalid digits (~`!#$%^&*()+=?/). This is not working yet, I don't know why. In addition, I would like both fields to require from 1 to 12 digits for submition to continue. The text field also Lowers Case, can you tell me how to do the same on...
3
2889
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 page, and code to close the window. ------------------------------------------ the help window code is following <SCRIPT LANGUAGE="JavaScript"> <!-- Begin
2
2200
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. //Assume JavaScript enabled browsers and popups allowed. //Function to open the window function openWin(elm){ var nHeight = 250; var nWidth = 250; var nXpos = (screen.availWidth - nWidth) / 2;
4
2597
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. If the user change idea and select another OPTION, the TEXT input field should be disabled again. I hope I'm understandable. Sorry for my bad English.
5
2992
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 field 1 to field 3, then field 2 text and field 3 move to field 1 and field 2. I add the new order of text into an array so when the onDragEnd event
3
3190
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 navigate to the desired option quickly just by typing out the name. For example if I want to choose "Other" (All the options are arranged alhabetically within the Drop-down box) from Drop-down and if I Type "O" then I navigate to first entry with...
1
2319
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 in the text area these three addresses divyasanam@yahoo.com,ewew@yah.com,gjh@yahoo.com and now when I click on send email a ComposeMail window in outlook
4
4650
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 have been successfully registered.</div>"); within 1.5 seconds. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
8
8707
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 the title field gets its information from a previouse page so its value can easily be over 40 chars. (I can not restrict the length on the previouse page.) The major dificulty is that there is no form on the aspx page, and I do not have access to...
1
1403
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 to go into a different input field. I have the code below to help visualise what I am trying to do. I think what I want is similar to a calendar where you can select the date you want and it appears in an input field - this I can do, but can't...
0
8361
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8807
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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 we have to send another system
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.