473,320 Members | 2,180 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,320 software developers and data experts.

document.forms problem

I have some code on a page that will enable/disable a text box if a
checkbox has been checked/unchecked and it seems to be working fine
unless there is only one checkbox and one text box.

Here is the javascript:

function EnableCustLoyaltyNotes(x,y)
{
if (document.frmCustLoyalty.VoidLineID[x].checked ||
document.frmCustLoyalty.UnVoidLineID[x].checked)
{
document.frmCustLoyalty.Notes[y].disabled = false;
}
else
{
document.frmCustLoyalty.Notes[y].disabled = true;
}
}

Pretty simple, here is the code on the page:

onClick="EnableCustLoyaltyNotes('0','0');"

Any ideas on why its not working?

Thanks,
--Mike

Jun 27 '06 #1
1 1455
mi**@mcarlson.net wrote:
I have some code on a page that will enable/disable a text box if a
checkbox has been checked/unchecked and it seems to be working fine
unless there is only one checkbox and one text box.

Here is the javascript:

function EnableCustLoyaltyNotes(x,y)
{
if (document.frmCustLoyalty.VoidLineID[x].checked ||
document.frmCustLoyalty.UnVoidLineID[x].checked)
{
document.frmCustLoyalty.Notes[y].disabled = false;
}
else
{
document.frmCustLoyalty.Notes[y].disabled = true;
}
}

Pretty simple, here is the code on the page:

onClick="EnableCustLoyaltyNotes('0','0');"

Any ideas on why its not working?


Yes. When using expressions like:

document.formName.elementName

and there is only one form control in the form formName with a name of
elementName, then it will return a reference to that element. If there
is more than one form control with the name, it returns a collection of
those elements.

When you do: document.frmCustLoyalty.VoidLineID[x] and there is only
one control named 'VoidLineID' then there is (almost certainly) no
property x (or of whatever value was assigned to x).

You need to test whether the returned value is a single element or a
collection - read the FAQ :-)

<URL:http://www.jibbering.com/faq/#FAQ4_13>
--
Rob

Jun 28 '06 #2

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

Similar topics

4
by: Jan-Friedrich Mutter | last post by:
Hi, I have a problem to access a hidden field by javascript. The name of the field has a dot in it. That's the problem. But I need that dot because it is a "Stuts Property". I'm using IE 6....
2
by: Dave | last post by:
I have a page which uses JavaScript to create form elements using document.createElement('input'), etc.. Both Firefox and IE have no problem accomplishing this and when the form is submitted all...
15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
4
by: Omar | last post by:
Hi, I've been working with this without problems: function regresaValor() { var indexValor = document.forms.eleccion.selectedIndex; var valueValor = document.forms.eleccion.options.value;...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: suresh | last post by:
Hello to you all In my .Net application, I want to import document images (Tiff images), having same format, in a batch, For e.g. I have a document folder containing mixed images like...
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
6
by: Eric | last post by:
Hello, I have code similar to: if (beforeToday(document.forms.sStartDate.value)) that was broken when an include file had a form added to it. Since my form was no longer the 0th form, my...
6
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
5
by: ankit1999 | last post by:
I have a problem, everytime i'm run this page http://click2travel.in/index.php i get the this error,,,
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.