Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript help on updating button on instant

Status
Not open for further replies.

buckeyeleaf1979

Programmer
Apr 8, 2018
3
US
hello, new member here. kinda new to javascript but not to coding.


so I wrote a page in mainly php with a few javascript components. Right now in the body of the page i a looping output from the database and match it against an array. each row has a button that toggles from "add record" to a green button depending if the record is a match from the array.

When the page is loaded it stores into an array of records from the database. if there is a match, it will show the green button. When you hit the add button, it calls a function in the head and adds the record then displays a popup that it was added.

The question i have is, how can i add the new record to the array then have the button in the body change instantly?

javascript_question_pcexq0.jpg
 
Update the required element when the 'pop up' windows is closed/opened/acknowledged.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
chris,

Thank you for the reply. so do you mean put the button and green light in div tags and alter the div ? can you please provide me an example?
 
Well assuming you already have code that draws the indicators as circular dots ( for example, and the spans all have id attributes, you would simply change the background colour of the relevant span.

JavaScript:
      document.getElementById('elementid').style.backgroundColor='green';


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top