473,394 Members | 1,813 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,394 software developers and data experts.

dynamically changing two text fields dependent on each other

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
constraints. I won't bore you with the details as to why, but this
can't be a form verification thing where you get a warning when both
fields have a non-zero value. It has to be where if you enter a value
in one, the other becomes 0 and vice versa.

Any suggestions?

Oct 27 '06 #1
4 1572
ASM
toodi4 a écrit :
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.
<form>
<input name=one
onkeyup="if(this.value!=0 && this.value!='') two.value=0;">
<input name=two
onkeyup="if(this.value!=0 && this.value!='') one.value=0;">
</form>
Oct 27 '06 #2
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.

<form>
<input name=one
onkeyup="if(this.value!=0 && this.value!='') two.value=0;">
<input name=two
onkeyup="if(this.value!=0 && this.value!='') one.value=0;">
</form>
Thanks. I knew it was something simple.

Oct 27 '06 #3

ASM wrote:
toodi4 a écrit :
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.

<form>
<input name=one
onkeyup="if(this.value!=0 && this.value!='') two.value=0;">

You shouldn't assume that the unqualified identifier "two" will be
resolved as a control within the form. The above (and the following
script snippet) would be safer as:

onkeyup="if(this.value!=0 && this.value!='')
this.form.two.value=0;">

--
Rob

Oct 27 '06 #4
ASM
RobG a écrit :
ASM wrote:
><form>
<input name=one
onkeyup="if(this.value!=0 && this.value!='') two.value=0;">

You shouldn't assume that the unqualified identifier "two" will be
resolved as a control within the form.
that was working with my NC4 in the last century
so ..
it yet has to work everywhere !
if not : bad browser, to change browser !
The above (and the following
script snippet) would be safer as:

onkeyup="if(this.value!=0 && this.value!='')
this.form.two.value=0;">
Yes, but so much longer (taller, bigger, larger, ...)

Cordially
--
ASM
Oct 27 '06 #5

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

Similar topics

10
by: Paul Kooistra | last post by:
I need a tool to browse text files with a size of 10-20 Mb. These files have a fixed record length of 800 bytes (CR/LF), and containt records used to create printed pages by an external company. ...
10
by: Free-Ed, Ltd. | last post by:
I am going nuts trying to find a paragraph in a book that described how to change the text content (HTML) in a DIV. Actually I have an array of HTML strings that I want to drop into the DIV,...
9
by: Paul Morrow | last post by:
I have seen the technique where a number of rows in a database are displayed in an html table so that each column of each row is editable. They use a single form surrounding the table, where each...
11
by: Randell D. | last post by:
Folks, I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes. How can I therefore make an input...
10
by: Kathy Burke | last post by:
HI. in asp.net app, I have an xmlDocument that I transform to the client html. Using xsl I create a few textboxes to capture user input. Each of these are related to <data> elements in the xmlDoc....
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
6
by: Dan Dorey | last post by:
I actually have two questions here, but I'll start by giving an outline of what I'm trying to do. I'm building an app with a simple plugin architecture (all in the same app domain). I have each...
2
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
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...
0
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,...
0
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...
0
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...

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.