473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable is losing value after second loop iteration.

23 New Member
The below code is calling a function that populates a certain number of listbox es with options. IT loops as it should if there are only 2 instances of k, but anything greater and the second variable being passed, document.getEle mentById(), loses value, so the populateList function cannot find ANY of the elements.

Expand|Select|Wrap|Line Numbers
  1.  if (tip>1){
  2.  document.getElementById("grpbook").style.visibility="visible";
  3.  document.form1.unit.style.visibility="visible";
  4.  removeChildren(trow);
  5.  removeChildren(grow);
  6.  addcolumn('indguest', gtg, 'glft', 2, 'glft');
  7.  addcolumn('indguest', gt3, 'l', 3, 'gname');
  8.  addcolumn('glist', '<strong>Guest List:</strong>', 'gllft', 1, 'grplist');
  9.  addcolumn('glist', tmp, 'l', 4, 'gnlist');
  10.      if (document.getElementById("air").checked){
  11.     populateList("airforce", document.form1.Rank2);
  12.         for (var k=0;k<tip;k++) {
  13.         var gr="gRank"+k
  14.             populateList("airforce", document.getElementById(gr));
  15.         }
  16.     }
  17.     else{
  18.     populateList("navy", document.form1.Rank2);
  19.         for (var k=0;k<tip;k++) {
  20.         var gr="gRank"+k
  21.             populateList("airforce", document.getElementById(gr));
  22.         }
  23.     }
  24.  
  25.  }
Mar 7 '07 #1
2 2071
iam_clint
1,208 Recognized Expert Top Contributor
i am having a hard time following your code

explain what your trying to accomplish and a link so i can visualize it please it helps greatly when i can really see whats going on.
Mar 7 '07 #2
Vanecelli
23 New Member
Actually, I figured it out, albeit way late last night. :)
I was missing one lousy character in the elements name. Figures, looking for a big problem, and it's really simple. Thanks for the look anyway.
Mar 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3741
by: Gord | last post by:
Hello, I think that what I'm trying to do is impossible, but before I give up I thought I'd try and pick a few more knowledgeable brains than my own. I have any array of user defined type variables. I need to loop through the array (doing certain calculations) on a particular member variable. I then want to loop through the array again on a different member variable doing very similar calculations. I only need to change a couple...
5
3336
by: Vasileios Zografos | last post by:
Ok, easy question. Not caring about the variable scope what is better (i.e. possibly in memory allocation etc) int someVar=0; for (int i=0;i<1000;i++) { ...
3
2869
by: Thomas Matthews | last post by:
Hi, While coding programs, I cam about a conundrum regarding variables defined in an iterative loop. The issue is whether it is more efficient to factor the definition out of the loop or maintain encapsulation by leaving it inside the loop? Common stuff for examples: class Data;
5
4136
by: Marc Rivait | last post by:
Here is a very interesting scenario. I have a simple test application that loads a page and sets a session variable on the load event. On the first page there is a link to a second page. The load event of the second page displays the value of the session variable. The problem is that when I use a W2k machine, this little test works perfect. Session variable value is displayed on the second page. However, when I use my XPPro...
4
2172
by: Stephen | last post by:
I have a .NET (1.1 framework) application that is losing a session variable on only a few PC's. The main page is loading up in a frame in a Portal application. On the Page_Load it stores an object with the user id and password into the session. The web page includes a set of links. When the user clicks on a link, another page within this application is opened in a new window. On the Page_Load of this second page, I am retrieving...
7
1517
by: Garry Jones | last post by:
I have an entry page which can be used to key in data for ten people. My assigned variables for each field are in line with $personage1 $personage2 ....etc $personage9 $personage10 and so on. (I have 8 fields for every person, 80 values in all).
29
5120
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is: 65,535. But i'm trying to write a program to test this, assuming I didn't know this number in advance. I came up with the following but have two questions. Maybe someone can help? using System; using System.Collections.Generic; using System.Text;
20
12766
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
1
3369
by: greyseal96 | last post by:
Hi, I am a pretty new programmer, so I apologize in andvance if this is a dumb question... In a book that I'm reading to learn C#, it says that when using a foreach() loop, a read-only copy of the iteration variable is used and you cannot modify it. For example: int pins = {9, 3, 7, 2} int newPin = 10; foreach(int pin in pins) {
0
9699
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
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
10538
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
10305
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
10285
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
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...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.

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.