Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 63853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:41:53+00:00 2026-05-10T18:41:53+00:00

I have this function in my Javascript Code that updates html fields with their

  • 0

I have this function in my Javascript Code that updates html fields with their new values whenever it is called. The problem cannot be with the function itself because it works brilliantly in every section except for one. Here is the JS function:

  function updateFields() {     document.getElementById('bf').innerHTML = bill.time[breakfast][bill.pointPartOfWeek];     document.getElementById('ln').innerHTML = bill.time[lunch][bill.pointPartOfWeek];     document.getElementById('dn').innerHTML = bill.time[dinner][bill.pointPartOfWeek];     document.getElementById('se').innerHTML = bill.time[special][bill.pointPartOfWeek];     document.getElementById('fdr').innerHTML = bill.time[full][bill.pointPartOfWeek];     document.getElementById('cost').innerHTML = bill.cost;   } 

And it executes fine in the following instance:

  <select onchange='if(this.selectedIndex == 0) {bill.unholiday();updateFields()} else { bill.holiday();updateFields()}' id='date' name='date'>     <option value='else'>Jan. 02 - Nov. 20</option>     <option value='christmas'>Nov. 20 - Jan. 01</option>   </select> 

but in this very similar code, the last line of the function doesn’t seem to execute (it doesn’t update the cost field, but updates everything else)

  <select onchange='if(this.selectedIndex == 0) {bill.pointPartOfWeek = 1;} else { bill.pointPartOfWeek = 2;}updateFields();alert(updateFields());' id='day' name='day'>     <option value='0'>Monday thru Thursday</option>     <option value='1'>Friday, Saturday, or Sunday</option>   </select>   <br /> 

Strangely enough, the total cost variable itself is updated, but the field that represents the variable is not. If you use another section of the page that wouldn’t change the value of the total cost but calls the updateFields function again, the cost field then updates correctly. It must be an issue with the function called.

Note: we know that the function executes because it does 5 out of 6 of the things it is supposed to do. This is a strange issue.

Edit: The pastebin for the entire page my be helpful. Here it is:

http://pastebin.com/f70d584d3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:41:54+00:00Added an answer on May 10, 2026 at 6:41 pm

    I’m curious, is it possible that there are actually 2 elements with an id of ‘cost’? That could, by updating the first one it finds, cause this issue. Different browsers may have different ways of implementing document.getElementById() so you might get even more inconsistent results with different browsers if this is the case.

    UPDATE: It turns out that you need to call bill.holiday() or bill.unholiday() before calling updateFields() in your second select.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 146k
  • Answers 146k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What we tried (and successfully) kill the problem. JAVA -… May 12, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Psychic debugging: You're writing the output in text mode on… May 12, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer This is nothing more than adding a <DIV> that covers… May 12, 2026 at 9:06 am

Related Questions

I need to find a way to call a vb.net function in my aspx
Hey everyone, I'm working on a widget for Apple's Dashboard and I've run into
I get the following error in firebug in Firefox 3 with both MooTools and
I have an application that I am writing that modifies data on a cached

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.