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

Reloading an HTML element populated by Javascript

First, let me thank acoder for his/her help with my last javascript problem.

I have a new problem though.

I have a simple form that uses selection boxes and I wanted the boxes to be smart. As I have said before, I do not have access to the server side system so I have to add the smarts on the client side.

it is simple, month day year.

I have the months set as static HTML with values from 0 to 11 accordingly. I have set the page to run my "fillDay()" function onload, which proceeds to properly fill in the correct number of days for the month.... January being the one that is set at the start.

The "Days" select box is populated through appendChild() calls. The problem arises when I go to change the month. when fillDay runs again, it continues to append to the initial list rather than simple replace the items.

I have tried code that should remove the child nodes first:

Expand|Select|Wrap|Line Numbers
  1. while(slctDay.hasChildNodes()){
  2.                 slctDay.removeChild(slctDay.firstChild);
  3.  
but it did not remove the appended elements.

What can I do to remedy this? is there a way to reload a single element on the page?

Thanks,

Jeremy
Nov 22 '07 #1
1 1989
I figured it out (why is it always the very next page in google after you post a question that gives you an answer?)

Expand|Select|Wrap|Line Numbers
  1. while(slctDay.childNodes[0]){
  2.   slctDay.removeChild(slctDay.childNodes[0]);}
I attempted this with a for loop and an iterator but it resulted in a hard crash of my browser. I wondered why until I realized, as it removed the nodes, the indexes of the remaining nodes changed so when I got half way through I buffer overflowed the array and it crashed the browser.
Nov 22 '07 #2

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

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
2
by: Charlie | last post by:
Hey all: I have a very simple script that changes an image when the user 'OnMouseOver's it. it works without a problem, but the progress bar at the bottom of the browser window reappears with...
1
by: Izzet Pembeci | last post by:
I am trying to display some rss feeds in my homepage. To do that I am using an external script which returns smth like: document.writeln("<div ...>") document.writeln("Title of News 1") !! read...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
2
by: TB | last post by:
Hi All: A very simple question, which I hope has a simple answer: On page.aspx I have two user controls: part1.ascx and part2.ascx How can I trigger the reloading of part2.ascx from within...
5
by: dwmartin18 | last post by:
Hello everyone. I have quite the puzzling problem with a script I have been working on lately. I have created a function that can be called to create a new html element (e.g. input, select, div,...
19
by: david.karr | last post by:
If in my CSS I set the "background-color" property on the "body" element, it only covers the background of the elements defined in the body, up to the current width and height of the page. However,...
4
by: sarega | last post by:
Hi, I have a text box, when a user enters some value into the text box, that value has to be populated in the url and as well as the value entered in that text box has to be retained. <? echo...
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:
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.