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

Variable is losing value after second loop iteration.

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.getElementById(), 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 2044
iam_clint
1,208 Expert 1GB
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
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
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...
5
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
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...
5
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...
4
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...
7
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...
29
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:...
20
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...
1
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...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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.