473,802 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing value of text fields not inside form

Why doesn't this work? :-

<BODY onkeydown="disp lay(event)">
<input type="text" name="text1">
<script language="Javas cript">
function display(event) {
document.text1. value = event.keyCode+' : '+String.fromCh arCode(event.ke yCode);
}
</script>
</BODY>

Error: document.text1 has no properties

I have to put it in a Form to get it to work :-

<BODY onkeydown="disp lay(event)">
<form name="form1">
<input type="text" name="text1">
</form>
<script language="Javas cript">
function display(event) {
document.form1. text1.value = event.keyCode+' : '+String.fromCh arCode(event.ke yCode);
}
</script>
</BODY>
Jul 23 '05 #1
1 1530
songkau wrote:
Why doesn't this work? :-

<BODY onkeydown="disp lay(event)">
<input type="text" name="text1">
<script language="Javas cript">
function display(event) {
document.text1. value = event.keyCode+' : '+String.fromCh arCode(event.ke yCode);
}
</script>
</BODY>

Error: document.text1 has no properties

I have to put it in a Form to get it to work :-

<BODY onkeydown="disp lay(event)">
<form name="form1">
<input type="text" name="text1">
</form>
<script language="Javas cript">
function display(event) {
document.form1. text1.value = event.keyCode+' : '+String.fromCh arCode(event.ke yCode);
}
</script>
</BODY>

It is OK to put form controls into an HTML page without making
them part of a form. However, if you do, you don't have access
to certain features that are available when they are part of a
form. For example, they can never be successful and so can't be
submitted as if they were in a form.

Have a read here:

<URL:http://jibbering.com/faq/faq_notes/form_access.htm l>
--
Rob
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
11062
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
8
3373
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care about in the submitted action. I'd therefore like to get rid of them by doing something like:
4
2449
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. The first class handles the form generation - (this was done using GUI form designer).
7
8990
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and then change the label in front of the textbox or dropdown list to red... is this possible with asp.net? It seems you can only put a RequiredFieldValidator on the page, and if it fails validation then that text is displayed... ? Thanks
32
3701
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's RecordSource like this? Am I asking for trouble doing this with a memo field? Thanks in advance. Private Sub cmdNextNote_Click() Dim lngNid As Long If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
1
2686
by: mplus_2000 | last post by:
I have recently inherited a database. The switchboard (and other forms) displays the name of the database on it (top, center). Currently the name that appears is Reviews. There are plans to roll out the application (i.e. making copies of the database) to other locations (Reviews-NY, Review-Dallas etc). If was mentioned today in passing by the original developer that there is a way to change the title that appears on the switchboard without...
2
1736
by: sheldonlg | last post by:
I have what is probably a very simple question, but I am VERY new to javascript. Here is what I want to accomplish. I have a text box called zp. I also have a hidden field called frm. There is also a submit button. When the submit button is pressed, I want to set the value of the hidden field, frm, depending upon whether or not there the text field, zp, is empty. For example, if it is empty I want the hidden field to be frm="empty"...
4
1594
by: toodi4 | last post by:
Something tells me this is a simple problem, but I seem to be stuck. I am working on a form in which there are two text fields which can contain numerical values. But only one of them can have a value other than zero. So if the first one has a value, the second one becomes zero, and if you then enter a value in the second one, the first one reverts to 0. I didn't create this form originally and so I am working within some...
1
2653
by: peck2000 | last post by:
Related to my earleir post ... this is the same project to re-purpose the Classifieds application in BEGINNING ASP 3.0 (Wrox) to a comicbook database ... This is a brainteaser that should have been easy to resolve but just doesn't seem to work for me ... The original application includes a form page for editing the details of an "item". In my case the item is a comicbook. The page functions just fine as long as I stick with text fields, but I...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10303
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
10282
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,...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
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
5494
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4270
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
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.