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

hideously, painfully annoying problem of death

WHY, oh WHY, won't my cute little js work? it consistently returns
"initial", that is, it fails to update the hidden field value. PLEASE
help a humbled, annoyed fellow programmer.

var html='<input type="hidden" name="length" value="initial"/>';

var value=1;

document.write(html);
increaseValue();

function increaseValue()
{
value++;
document.getElementsByName('length').value=value;
}

cheers
dave

Jul 23 '05 #1
7 1043
On 4 Oct 2004 02:58:26 -0700, ma**********@hotmail.com wrote:
WHY, oh WHY, won't my cute little js work? it consistently returns
"initial", that is, it fails to update the hidden field value. PLEASE
help a humbled, annoyed fellow programmer.

var html='<input type="hidden" name="length" value="initial"/>';

var value=1;

document.write(html);
increaseValue();

function increaseValue()
{
value++;
document.getElementsByName('length').value=value;
}


Off of my head, I would say that getElementsByName() (Are you sure there is
such a method? I have never heard about it; there are getElementById and
getElementsByTagName, but I don't know everything...) doesn't return a
single object but a collection of objects (since there can be more than one
element of the same name.

Use either ID and getElementById, or (if I am correct)
document.getElementsByName('length')[0].value
Jul 23 '05 #2
On Mon, 4 Oct 2004 12:08:15 +0200, Berislav Lopac
<be************@dimedia.hr> wrote:

[snip]
Off of my head, I would say that getElementsByName() (Are you sure there
is such a method? I have never heard about it; there are getElementById
and getElementsByTagName, but I don't know everything...)
There is a method called getElementsByName (which I keep forgetting
about...). It is part of the HTMLDocument interface (implemented by the
document object) as described in the DOM HTML Specification.
doesn't return a single object but a collection of objects (since there
can be more than one element of the same name.
....and it does return a collection
Use either ID and getElementById, or (if I am correct)
document.getElementsByName('length')[0].value


Alternatively, if the element is the descendant of a form:

document.forms['formName'].elements['length'].value

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
ahhh ok, all good now. thanks for that guys.

cheers
dave

Jul 23 '05 #4
Ivo
"Michael Winter" wrote:
Alternatively, if the element is the descendant of a form:

document.forms['formName'].elements['length'].value


Additionally, naming a form element 'length' is asking for trouble, since

document.forms['formName'].elements.length

is already where the number of elements is stored...

--
Ivo
Jul 23 '05 #5
On Mon, 4 Oct 2004 13:02:01 +0200, Ivo <no@thank.you> wrote:

[snip]
Additionally, naming a form element 'length' is asking for trouble [...]


Good point. I missed that.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #6
lol yeah i need myself a decent thesaurus for my variable names

Jul 23 '05 #7
ma**********@hotmail.com wrote in message news:<10**********************@k17g2000odb.googleg roups.com>...
WHY, oh WHY, won't my cute little js work? it consistently returns
"initial", that is, it fails to update the hidden field value. PLEASE
help a humbled, annoyed fellow programmer.

var html='<input type="hidden" name="length" value="initial"/>';

var value=1;

document.write(html);
increaseValue();

function increaseValue()
{
value++;
document.getElementsByName('length').value=value;
}

cheers
dave


Personally, I wouldn't use "value" as the name of a javascript
variable. Just asking for trouble somewhere along the way. I'm
surprised it works.
Jul 23 '05 #8

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

Similar topics

47
by: Daniel Silva | last post by:
Shriram Krishnamurthi has just announced the following elsewhere; it might be of interest to c.l.s, c.l.f, and c.l.p: http://list.cs.brown.edu/pipermail/plt-scheme/2005-April/008382.html The...
0
by: Rick | last post by:
I am a novice to embedded XP. I have an application that makes a call to the ManagementClass to get the MAC address. This code runs fine on XP professional and XP home, but when I copy the...
20
by: dukeleto | last post by:
I know this is an annoying thing on some sites. I have set some images in an online gallery to have their own java po up window that is set to be the same size as the image. I would like to...
3
by: Marc Castrechini | last post by:
Forgive me on the lack of specifics but I am not a "server" guy. We just rolled our code out to a 2003 Server from Win2k Server and for some reason our pages are painfully slow. It appears the...
1
by: =?Utf-8?B?RGpub3J0aHl5?= | last post by:
Hey guys, i am having a problem with my pc. It is running XP Home and is an advent. Sometimes it does it when it starts up or some times jsut randomly. Here is the error code: 0x0000003...
102
by: BoogieWithStu22 | last post by:
I am running into a problem with a web page I have created when viewing it in IE6 on some machines. The page has a database lookup. The user enters an account name or number and clicks a lookup...
1
by: James | last post by:
Database was no responding when user did some query operation. I checked db2diag.log and found EDU error mentioned in it. I pasted them below. I am not sure how to sovle it. Any advice? Thanks in...
84
by: braver | last post by:
Is there any trick to get rid of having to type the annoying, character-eating "self." prefix everywhere in a class? Sometimes I avoid OO just not to deal with its verbosity. In fact, I try to...
6
by: Rocketmagnet | last post by:
Hi all, I have been kind of forced (honestly) into writing a class structure which contains a Diamond of Death, and I'm not entirely sure what to do about it. This is a simplified version of my...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.