Click here to Skip to main content
14,608,161 members

JavaScript

 
GeneralRe: Javascript function error. Pin
Richard MacCutchan13-Jun-20 6:31
mveRichard MacCutchan13-Jun-20 6:31 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 11:48
Memberand180y13-Jun-20 11:48 
GeneralRe: Javascript function error. Pin
jkirkerx13-Jun-20 7:36
professionaljkirkerx13-Jun-20 7:36 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 11:47
Memberand180y13-Jun-20 11:47 
QuestionJavaScript slide show works bad on the first page load Pin
Hypnonis8-Jun-20 20:03
MemberHypnonis8-Jun-20 20:03 
AnswerRe: JavaScript slide show works bad on the first page load Pin
Richard Deeming8-Jun-20 22:30
mveRichard Deeming8-Jun-20 22:30 
GeneralRe: JavaScript slide show works bad on the first page load Pin
Hypnonis9-Jun-20 6:33
MemberHypnonis9-Jun-20 6:33 
QuestionJSON object not showing values.. Can someone help Pin
Member 35640766-Jun-20 4:33
MemberMember 35640766-Jun-20 4:33 
Code is here:-


<!DOCTYPE html>
<html lang="en-US">
<head>
</head>
<body>
  
{% csrf_token %}
    
<script>  

//Your string
    
let a = "{{models}}"    
a = a.replace(/"/g, '"');
a = a.replace(/(?:\r\n|\r|\n)/g, '');

let stringToParse = JSON.stringify(a);      
//document.body.innerHTML = `<p> Received String: ${stringToParse}</p>`;

//Converting your string to object
let convertedToObject = JSON.parse(stringToParse);
document.body.innerHTML = `<p> Received String: ${convertedToObject}</p>`;

//Getting the boardMembers list from your parsed object
let listBoardMembers = convertedToObject.boardMembers;
let listExecutives  =  convertedToObjects.executives;    

document.body.innerHTML = `<p> listboard: ${listBoardMembers}</p>`;
document.body.innerHTML = `<p>  listexecutives: ${listExecutives}</p>`;
   
    
//Creating Elements on HTML (creating a Paragraph with the received data and a container for the list of members). *Notice: I've created a "DIV" (container) with a unique ID ("listMembers"). This is important because when I start to iterate the members I will add them inside the container, and for that, I need to reference it using an ID.*

//document.body.innerHTML = `<p> Received String: ${convertedToObject}</p>`;
document.body.innerHTML += `<div id="listMembers"></div>`;

//Iterating the list of boardMembers using this length;
for (let i = 0; i < listBoardMembers.length; i++) {
  let member = listOfMembers[i];

  let memberName = member.name;
  let memberImageURL = '';

  // Verify if the user has thumbnail
  if (member.thumbnail !== null){
     memberImageURL = member.thumbnail.url;
  }

  //Adding this member to the member's container, using the container ID, that we created previously.

  document.getElementById('listMembers').innerHTML += `
     <div style="display: flex;">
       <img src="${memberImageURL}">
       <h1>${memberName}</h1>
     </div>
  `;
}
      
  </script>
</body>
</html>




JSON object is here:-


{"boardMembers": [{"id": "7394026", "name": "Stephen Joseph Squeri", "slug": "7394026-stephen-joseph-squeri", "companyName": "American Express Co", "company": {"id": "AXP:US", "name": "American Express Co"}, "webVisibility": true}, {"id": "3994082", "name": "Ronald A Williams "Ron"", "slug": "3994082-ronald-a-williams-"ron"", "companyName": null, "company": null, "webVisibility": false}, {"id": "1439479", "name": "Theodore J. Leonsis", "slug": "1439479-theodore-j-leonsis", "companyName": "Monumental Sports & Entertainment", "company": null, "webVisibility": true}, {"id": "1499616", "name": "John Joseph Brennan "Jack"", "slug": "1499616-john-joseph-brennan", "companyName": "Vanguard Charitable Endowment", "company": null, "webVisibility": true}, {"id": "1501790", "name": "Dr Daniel L Vasella "Dan"", "slug": "1501790-dr-daniel-l-vasella-"dan"", "companyName": null, "company": null, "webVisibility": false}, {"id": "1512919", "name": "Anne Lauvergeon", "slug": "1512919-anne-lauvergeon", "companyName": null, "company": null, "webVisibility": false}, {"id": "1529307", "name": "Peter F Chernin", "slug": "1529307-peter-f-chernin", "companyName": "Chernin Group LLC/ The", "company": null, "webVisibility": true}, {"id": "1720518", "name": "Rafael De La Vega "Ralph"", "slug": "1720518-rafael-de-la-vega", "companyName": "Forte Capital Management LLC", "company": {"id": "0778486D:US", "name": "Forte Capital Management LLC/GA"}, "webVisibility": true}, {"id": "1805754", "name": "Michael O Leavitt "Mike"", "slug": "1805754-michael-o-leavitt", "companyName": "Leavitt Partners", "company": {"id": "0707795D:US", "name": "Leavitt Partners LLC"}, "webVisibility": true}, {"id": "1879736", "name": "Christopher D Young "Chris"", "slug": "1879736-christopher-d-young", "companyName": "Mcafee Inc", "company": null, "webVisibility": true}, {"id": "14003646", "name": "Charlene Barshefsky", "slug": "14003646-charlene-barshefsky", "companyName": "Wilmer Cutler Pickering Hale and Dorr LLP", "company": {"id": "1221L:US", "name": "Wilmer Cutler Pickering Hale and Dorr LLP"}, "webVisibility": true}, {"id": "17579429", "name": "Karen L Parkhill", "slug": "17579429-karen-l-parkhill", "companyName": "Medtronic PLC", "company": {"id": "MDT:US", "name": "Medtronic PLC"}, "webVisibility": true}, {"id": "21421355", "name": "Lynn A Pike", "slug": "21421355-lynn-a-pike", "companyName": null, "company": null, "webVisibility": false}], "totalBoardMembers": 13, "executives": [{"id": "7394026", "name": "Stephen Joseph Squeri", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iNnVt_wW9y_A/v3/80x80.jpg", "alt": null}, "title": "Chairman/CEO", "slug": "7394026-stephen-joseph-squeri", "webVisibility": true}, {"id": "20887787", "name": "Dr Mohammed Badi", "thumbnail": null, "title": "Chief Strategy Officer", "slug": "20887787-mohammed-badi", "webVisibility": true}, {"id": "18706279", "name": "Monique R Herena", "thumbnail": null, "title": "Chief Colleague Experience Officer", "slug": "18706279-monique-r-herena", "webVisibility": true}, {"id": "19676689", "name": "Elizabeth Rutledge", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iABmk_sWUnY4/v3/80x80.png", "alt": null}, "title": "Chief Marketing Officer", "slug": "19676689-elizabeth-rutledge", "webVisibility": true}, {"id": "18784925", "name": "Tangela Richter", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iKYkW0FlMRW4/v3/80x80.png", "alt": null}, "title": "Chief Governance Ofcr/Secy", "slug": "18784925-tangela-richter", "webVisibility": true}, {"id": "15024090", "name": "Laureen E Seeger", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iiw0z.pdTRbE/v1/80x80.jpg", "alt": "LAUREEN E SEEGER"}, "title": "Chief Legal Officer", "slug": "15024090-laureen-e-seeger", "webVisibility": true}, {"id": "21336581", "name": "Jennifer Skyler", "thumbnail": null, "title": "Chief Corporate Affairs Officer", "slug": "21336581-jennifer-skyler", "webVisibility": true}, {"id": "19676686", "name": "Raymond Joabar", "thumbnail": null, "title": "Pres:Global Risk/CRO", "slug": "19676686-raymond-joabar", "webVisibility": true}, {"id": "15365626", "name": "Douglas E Buckminster", "thumbnail": null, "title": "Group Pres:Global Consumer", "slug": "15365626-douglas-e-buckminster", "webVisibility": true}, {"id": "16654781", "name": "Anna Marrs", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iNFzMiuYiRGY/v3/80x80.png", "alt": null}, "title": "Pres:Global Commercial Svcs", "slug": "16654781-anna-marrs", "webVisibility": true}, {"id": "16804630", "name": "Denise Pickett", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iReOY_ZB0dOI/v2/80x80.png", "alt": null}, "title": "Pres:Global Services Group", "slug": "16804630-denise-pickett", "webVisibility": true}, {"id": "6832356", "name": "Anre D Williams", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iJ5kSc7LL.3Y/v2/80x80.png", "alt": null}, "title": "Pres:Global Merchant & Network Svcs", "slug": "6832356-anre-d-williams", "webVisibility": true}, {"id": "3221610", "name": "Jeffrey C Campbell "Jeff"", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iV0fAS1rb10o/v1/80x80.jpg", "alt": "35000014"}, "title": "Exec VP/CFO", "slug": "3221610-jeffrey-c-campbell", "webVisibility": true}, {"id": "16733751", "name": "Marc D Gordon", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/isa0AVbtpBaM/v3/80x80.jpg", "alt": null}, "title": "Exec VP/CIO", "slug": "16733751-marc-d-gordon", "webVisibility": true}, {"id": "21531045", "name": "Jessica Lieberman Quinn", "thumbnail": null, "title": "Exec VP/Controller", "slug": "21531045-jessica-lieberman-quinn", "webVisibility": true}, {"id": "19863566", "name": "Alan P Gallo", "thumbnail": {"url": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/i_G02QWHFys4/v3/80x80.jpg", "alt": null}, "title": "Exec VP:Internal Audit/Chief Audit Exec", "slug": "19863566-alan-p-gallo", "webVisibility": true}, {"id": "16310906", "name": "Vivian Zhou", "thumbnail": null, "title": "Senior VP/Head:Investor Relations", "slug": "16310906-vivian-zhou", "webVisibility": false}], "totalExecutives": 17}

GeneralRe: JSON object not showing values.. Can someone help Pin
Richard MacCutchan7-Jun-20 0:50
mveRichard MacCutchan7-Jun-20 0:50 
QuestionPyramid array Pin
Girardi.E30-May-20 0:48
MemberGirardi.E30-May-20 0:48 
AnswerRe: Pyramid array Pin
Richard MacCutchan30-May-20 1:15
mveRichard MacCutchan30-May-20 1:15 
AnswerRe: Pyramid array Pin
DerekT-P30-May-20 2:30
professionalDerekT-P30-May-20 2:30 
Questionidentify each node with its Id Pin
vikas@prajaktasoftware.com19-May-20 8:57
Membervikas@prajaktasoftware.com19-May-20 8:57 
SuggestionRe: identify each node with its Id Pin
ZurdoDev19-May-20 9:39
mveZurdoDev19-May-20 9:39 
QuestionReturn negative number as 0 Pin
and180y18-May-20 1:46
Memberand180y18-May-20 1:46 
AnswerRe: Return negative number as 0 Pin
Richard MacCutchan18-May-20 2:05
mveRichard MacCutchan18-May-20 2:05 
GeneralRe: Return negative number as 0 Pin
and180y18-May-20 2:27
Memberand180y18-May-20 2:27 
GeneralRe: Return negative number as 0 Pin
Richard MacCutchan18-May-20 2:40
mveRichard MacCutchan18-May-20 2:40 
AnswerRe: Return negative number as 0 Pin
Richard Deeming18-May-20 5:43
mveRichard Deeming18-May-20 5:43 
GeneralRe: Return negative number as 0 Pin
and180y18-May-20 13:10
Memberand180y18-May-20 13:10 
Questiongenerate a mongo bson objectId in angular V7+ Pin
jkirkerx17-May-20 12:51
professionaljkirkerx17-May-20 12:51 
QuestionHow to format the file containing json objects to json array Pin
kjeeva15-May-20 21:53
Memberkjeeva15-May-20 21:53 
AnswerRe: How to format the file containing json objects to json array Pin
Richard MacCutchan15-May-20 22:31
mveRichard MacCutchan15-May-20 22:31 
QuestionMatrix creation using array Pin
Member 1483368915-May-20 10:51
MemberMember 1483368915-May-20 10:51 
AnswerRe: Matrix creation using array Pin
Richard MacCutchan15-May-20 22:17
mveRichard MacCutchan15-May-20 22:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.