JavaScript - Cant Seem To Debug
Code:
<html> <head> <script type="text/javascript"> function go(){ var namev = document.getElementById("name").value; var imagev = document.getElementById("image").value; var idv = document.getElementById("id").value; var dov = document.getElementById("do").value; var descv = document.getElementById("desc").value; var varnv = document.getElementById("varn").value; document.getElementById("outcome").innerHTML = "var" + varnv + "= new Image();" + "<br/>" + varnv + ".src =" + imagev + ";" + "<br/>" + "<br/>" + "function pickup" + namev + "(){" + "<br/>" ; goa(); } function goa(){ document.getElementById("data").innerHTML += "if (document.getElementById("is1n").innerHTML == ""){"; + "<br/>" + "document.getElementById("is1i").src =" + imagev + "<br/>" + "document.getElementById("is1n").innerHTML =" + namev + "document.getElementById("is1d").innerHTML = " + dov + ";"; } </script> --> </head> Name<input type="text" value="a" id="name" />must have "" <br/> SRC<input type="text" value="a" id="image" />must have "" at each side <br/> ID<input type="text" value="a" id="id" />"" <br/> DO<input type="text" value="a" id="do" /> "" <br/> DESC<input type="text" value="a" id="desc" /> <br/> VAR<input type="text" value="a" id="varn" /> <input type="button" onclick="go();" value="create"/> <br/> <div id="outcome" CONTENTEDITABLE ></div> <br/> <div id="data" CONTENTEDITABLE ></div> </body> </html> It does not seem to write the function goa i used firebug and all it gives me is missing ; before statement Similar Tutorialswhat am i doing wrong? also can I add another http post to validate the credit card Code: function validateregister() { // alert("here"); var frm=document.forms['register']; var mobilenumber=frm.mobilenumber; http.abort(); http.open("GET", "validatemobile.asp?mobile=" + mobilenumber, true); // alert("here"); http.onreadystatechange=function() { if(http.readyState == 4) { var myresult = http.responseText; } } http.send(null); if(frm.mobilenumber.value==""){ alert("Please Enter your Mobile Number") return false; } if (myresult!="Valid"){ alert(myresult); return false; } if(frm.pin.value==""){ alert("Please Enter your Pin") return false; } return true; } what can be wrong with the below instead of calling the javascript function it is going to the homepage Code: <a href=# onClick="updatecart('2051')" class="button">Update</a> the following code is erroring does anyone know why? Code: <SCRIPT language=javascript> $(document).ready(function() { $("#catA").show(); $("table").css({ "clear": "left" }); $("img[@src='https://www.mysite.com/logos/bbb_logo.gif']").attr({"src":"http://www.mysite.com/logos/bbb_logo.gif"}); }); function showCat(which) { $(".cats").hide(); $("#cat" + which).show(); return false; } tabsAr = new Array("#product_listing", "#category_listing", "#brand_listing"); function flipTab(which) { $(tabsAr.join(",")).hide(); $(tabsAr[which]).show(); $("#tabs > li").removeClass("vlnk"); $("#tabs > li:eq(" + which + ")").addClass("vlnk"); } </SCRIPT> First off, I've been coming to this site over the past few months and it's been really helpful but I never needed help with anything up until now. I can't seem to find why this isn't working. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Days of the Week</title> </head> <script type="text/javascript"> <!-- HIDE FROM INCOMPATIBLE BROWSERS printDays(); // STOP HIDING FROM INCOMPATIBLE BROWSERS --> </script> </head> <body> <script type="text/javascript"> <!-- HIDE FROM INCOMPATIBLE BROWSERS function printDays() { daysOfWeek = new Array(7); daysOfWeek[0] = "Monday"; daysOfWeek[1] = "Tuesday"; daysOfWeek[2] = "Wednesday"; daysOfWeek[3] = "Thursday"; daysOfWeek[4] = "Friday"; daysOfWeek[5] = "Saturday"; daysOfWeek[6] = "Sunday"; var count = 0; do { document.write(daysOfWeek[count] + "<br />"); ++count; } while (count <= 6); } // STOP HIDING FROM INCOMPATIBLE BROWSERS --> </script> </body> </html> If anyone could point me in the right direction of what's wrong it'd really help. Can I debugge Javascript code to see which values take my variables? If so, How can I do it. thanks so much I've got this code below, it seems ok, but sometimes, the multiplication does not work..i don't know why... pls help me..thanks btw, this is my 1st javascript "application", so, im really new into this thanks in advance for any help Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>My First JavaScript Application</title> <style type="text/css"> td { text-align:center } table { background:#660033 } body { background-color:#666; text-wrap:supress; } h1 { color:#FFFFFF; } .ex { background-color:#99F; color:#660000; font:Verdana, Geneva, sans-serif; font-size:20px; text-align:right; } .ec { background-color:#CCC; color:#660033; font:Arial, Helvetica, sans-serif; font-size:18px; } </style> <script type="text/javascript"> var num1 = 0; var ope = 0; var num2 = 0; var ek = 0 function addOnScr1() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+1; document.getElementById("nums").value = txt; } function addOnScr2() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+2; document.getElementById("nums").value = txt; } function addOnScr3() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+3; document.getElementById("nums").value = txt; } function addOnScr4() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+4; document.getElementById("nums").value = txt; } function addOnScr5() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+5; document.getElementById("nums").value = txt; } function addOnScr6() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+6; document.getElementById("nums").value = txt; } function addOnScr7() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+7; document.getElementById("nums").value = txt; } function addOnScr8() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+8; document.getElementById("nums").value = txt; } function addOnScr9() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+9; document.getElementById("nums").value = txt; } function addOnScr0() { document.getElementById("neg").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+0; document.getElementById("nums").value = txt; } function addOnScrp() { document.getElementById("neg").disabled=true; document.getElementById("point").disabled=true; if((ek!=0)) { document.getElementById("nums").value = ""; ek = 0; } var txt = document.getElementById("nums").value; txt = txt+"."; document.getElementById("nums").value = txt; } function addOnScrn() { var txt = document.getElementById("nums").value; txt = txt+"-"; document.getElementById("nums").value = txt; } function add() { document.getElementById("neg").disabled=false; document.getElementById("point").disabled=false; ek=1; if(num1==0) { num1 = parseFloat(document.getElementById("nums").value); } else { ent(); } ope = 1; } function diff() { document.getElementById("neg").disabled=false; document.getElementById("point").disabled=false; ek=1; if(num1==0) { num1 = parseFloat(document.getElementById("nums").value); } else { ent(); } ope = 2; } function prod() { document.getElementById("neg").disabled=false; document.getElementById("point").disabled=false; ek=1; if(num1==0) { num1 = parseFloat(document.getElementById("nums").value); } else { ent(); } ope = 3; } function quo() { document.getElementById("neg").disabled=false; document.getElementById("point").disabled=false; ek=1; if(num1==0) { num1 = parseFloat(document.getElementById("nums").value); } else { ent(); } ope = 4; } function clr() { num1 = 0; num2 = 0; ope = 0; document.getElementById("nums").value = ""; document.getElementById("neg").disabled=false; document.getElementById("point").disabled=false; ek = 0; } function ent() { ek = 1; var ans; num2 = parseFloat(document.getElementById("nums").value); switch(ope) { case 1: ans = num1 + num2; document.getElementById("nums").value = ans; num1 = ans; break; case 2: ans = num1 - num2; document.getElementById("nums").value = ans; num1 = ans; break; case 3: ans = num1 * num2; document.getElementById("nums").value = ans; num1 = ans; break; case 4: ans = num1 / num2; document.getElementById("nums").value = ans; num1 = ans; break; default: document.getElementById("nums").value = "???"; } } function enterz() { document.getElementById("neg").disabled=false; document.getElementById("point").disabled=false; ek = 1; var ans; num2 = parseFloat(document.getElementById("nums").value); switch(ope) { case 1: ans = num1 + num2; document.getElementById("nums").value = ans; num1 = 0; break; case 2: ans = num1 - num2; document.getElementById("nums").value = ans; num1 = 0; break; case 3: ans = num1 * num2; document.getElementById("nums").value = ans; num1 = 0; break; case 4: ans = num1 / num2; document.getElementById("nums").value = ans; num1 = 0; break; default: document.getElementById("nums").value = "???"; } } </script> </head> <body><center> <form><h1> Calculator</h1> <table border="0"> <tr><th colspan="4"><input type="text" class = "ex" id = "nums" name = "nums" /></th></tr> <tr><td><button type="button" class = "ec" onclick="addOnScr1()">1</button></td> <td><button type="button" class = "ec" onclick="addOnScr2()">2</button></td> <td><button type="button" class = "ec" onclick="addOnScr3()">3</button></td> <td><button type="button" class = "ec" onclick="add()">+</button></td> </tr> <tr><td><button type="button" class = "ec" onclick="addOnScr4()">4</button></td> <td><button type="button" class = "ec" onclick="addOnScr5()">5</button></td> <td><button type="button" class = "ec" onclick="addOnScr6()">6</button></td> <td><button type="button" class = "ec" onclick="diff()">--</button></td></tr> <tr><td><button type="button" class = "ec" onclick="addOnScr7()">7</button></td> <td><button type="button" class = "ec" onclick="addOnScr8()">8</button></td> <td><button type="button" class = "ec" onclick="addOnScr9()">9</button></td> <td><button type="button" class = "ec" onclick="prod()">*</button></td></tr> <tr><td><button type="button" class = "ec" id="neg" onclick="addOnScrn()">-</button></td> <td><button type="button" class = "ec" onclick="addOnScr0()">0</button></td> <td><button type="button" class = "ec" id="point" onclick="addOnScrp()">.</button></td> <td><button type="button" class = "ec" onclick="quo()">/</button></td></tr> <tr><td></td> <td><button type="button" class = "ec" onclick="enterz()">=</button></td> <td><button type="button" class = "ec" onclick="clr()">C</button></td><td> </td></tr> </form> </body> </html> Here is my html page, it just stays on the third image and will not change! Will someone debug the javascript for me please. Thanks Code: <html> <head> <title>Slideshow</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/slideshow.js"></script> <script type="text/javascript"> if (document.images) { preload_image_object = new Image(); // set image url image_url = new Array(); image_url[0] = "/images/chef1.jpg"; image_url[1] = "/images/chef2.jpg"; image_url[2] = "/images/chef3.jpg"; image_url[3] = "/images/chef4.jpg"; var i = 0; for(i=0; i<=3; i++) preload_image_object.src = image_url[i]; } </SCRIPT> <style type="text/css"> #slideshow_container{ width: 500px; height: 360px; margin: 10px auto; overflow: hidden; } #slideshow_container div{ width: 500px; height: 360px; position: absolute; </style> </head> <body onLoad="changeImage();"> <div id="slideshow_container"> <div id="counter"> 4 </div> <div class="behind"> <img src="images/chef1.jpg" /> </div> <div class="infront"> </div> </div> </body> </html> Ok i'm not sure if this should go here or in the CSS/HTML section as i don't even know where the "conflict" comes from... Here's two almost identical pages: http://www.pirate-punk.net/bugtest.php http://www.pirate-punk.net/index.php?page=bugtest2 With Firefox or Opera it works perfectly. But with Internet explorer (i tryed with IE8) the top menu will be displayed correctly only in bugtest.php page it's not working in the other page and the bug is on my WHOLE site There's also another mysterious bug that always appear on the same time, my donation button image is supposed to be at the bottom right corner of the screen, but when the menu finally works the donation button won't work.... It probably has a link with the other bug Also, one of the checkbox labels is disseapearing... it is really weird because on both page, it is the exact same header file that is included Anyway, i don't care about that donation button or the checkbox, but i really need to fix the menu and i've been messing with it for hours and hours. if someone can help me with this i will be forever grateful !! thanks a lot So I'm fairly new to HTML/CSS/Javascript and coding in general and I'm having a helluva a time decoding this. I've looked it over many times, and for many minutes but I really have to break down and look for help now. It must be a stupid error somewhere but nonetheless. I think it's pretty straightforward what it's supposed to do. Code: <html> <head> <script type="text/javascript"> function findCost() { var copies = document.getElementById("copyNum").value; if (copies<500) { var cost = copies * 0.25; } else if (copies>499 && <750) { var cost = copies * 0.22; } else if (copies>749 && <1000) { var cost = copies * 0.20; } else { var cost = copies * 0.18; } document.getElementById("totalcost").innerHTML = "The cost to print " + copies + "copies is $" + cost.toFixed(2); } </script> </head> <body> <h2>Printing Place</h2> <p>The Printing Place has different printing prices based on the number of copies to be printed:</p> <ul> <li>a. 0 - 499 copies = $0.25 per copy</li> <li>b. 500 - 749 copies = $0.22 per copy</li> <li>c. 750 - 999 copies = $0.20 per copy</li> <li>d. 1000 copies or more = $0.18 per copy</li> </ul> Enter the number of copies you would like:<br /> <input type="text" id="copyNum"> <input type="button" value="Calculate Cost" onClick="findCost()"> <p id="totalcost"></p> </body> </html> I just started a job doing classic asp and only have experiance with asp.net and no java scrpt How can i debug javascript in classic asp pages? i have no clue so If you know, please give baby steps that are idiot proof Thanks~ Code: strapplicantid=document.getElementById('applicantid').value; $.get("spt.asp"+ '?id=' + strapplicantid + '&rnde='+ Math.round(Math.random() * 10000), function(data){ alert("Data Loaded: " + data); }); alert("here"); why is the alert("here") happenign before the alert dataloaded. I want to be albe to load the html into the variable data and then use that variable. How is this possible to do? If you're reading this with intent to help- thank's; lol I know the title is terrifying... the explanation is a bit more So first a few constraints/givens: This is an WebApp on a client comp It is on a closed network so I cannot link the page The app is essentially a spaghetti work of code The entire thing is written with javascript (the running joke is it was AJAX before there was AJAX) It is limited to IE7 (gov controlled) Problem: Randomly this fun error started popping up and I am trying to figure out if it is a script error or DB error. Usually when this monstrosity throws a DB error it gives it in a fun little screen (no custom error handling that we know of). The page attempts to "load" (and by load I mean fire another script to "load" another tab) and this little pop-up throws Quote: ["Windows Internet Explorer"] | | | | | | | | | [ OK ] | If you envision that as a little windows message box it would have the title and then inside the box, absolutely no information, it's completely blank save a large yellow ! triangle and an "ok" box. I've looked through and through in the event logs for the machine and have found nothing. What I am trying to figure out is, using developer tools- is there a way to find out if/what script threw the error without setting any breakpoints? Can't really set the break points bc have no clue where to put them and there are around 30 scripts calling more scripts and bouncing back and forth btw scripts. In short, it is a nightmare. I have a page that is not displayable under Internet Explorer 8.0 (Chrome and Mozilla Firefox works fine), and the error is Message: 'clickcategoryID' is undefined Line: 50 Char: 2 Code: 0 URI: /includes/javascript/template_functions.js Below is the line from the template_functions.js where it is troubling, can anyone help me correctly identify it. S.O.S! function clickmenuhover() { if(!document.getElementById(clickcategoryID)) return false; ========================================================= function Rollover(imagename, image, over) { if(window.document.images) { if(over) { window.document.images["sdhover" + imagename].src = image; } else { window.document.images["sdhover" + imagename].src = image; } } } function ToggleCommentDiv(elm, hiddenDivName, ShowText, HideText) { var hiddenDiv = document.getElementById(hiddenDivName); if(hiddenDiv.style.display == 'none') { elm.innerHTML = HideText; hiddenDiv.style.display = 'block'; } else { elm.innerHTML = ShowText; hiddenDiv.style.display = 'none'; } } function ViewAllComment(url) { window.open(url, '', 'width=600, height=auto, resizable=yes,scrollbars=yes'); } function addLoadToEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); }; } } function clickmenuhover() { if(!document.getElementById(clickcategoryID)) return false; document.getElementById(clickcategoryID).className = 'categoryclick'; } addLoadToEvent(clickmenuhover); ======================================================== my code is below what i want this to do is take the x_cityid and add it to teh hidden field with the id of citiesid (I will do an ajax call before this but my simple javascript is not working) what am i doing wrong? function addtocitylist() { var x_cityid = document.getElementById('x_cityid'); var x_areaid = document.getElementById('x_areaid'); var scitiesid=document.getElementById('citiesid'); var areasid = document.getElementById('areasid'); if (!scitiesid) { scitiesid.value = x_cityid; } else { scitiesid.value = scitiesid + ',' + x_cityid; } scitiesid.value = scitiesid ; alert(scitiesid); } Hello I am relatively new to java script. The code I have behaves differently when I debug it and when I just run is straight. There are three functions that one another in a particular sequence. When I debug it they get called in the correct sequence but otherwise they get called in a constant but random pattern. I know I am missing basic understanding of javascript Can some body help please. Thanks in advance Output when I open the page in a browser without debug. Code: Firebug's log limit has been reached. 0 entries not shown. Preferences readJSON2 There are no child objects inside parseJSON: There are no child objects GET http://10.208.137.92/js/v1/External/JSON/sample.json GET http://10.208.137.92/js/v1/External/JSON/sample.json 304 Not Modified 64ms jquery-1.6.2.js (line 7869) readJSON1 alerts [Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}] Console Output when I debug Code: Firebug's log limit has been reached. 0 entries not shown. Preferences Firebug's log limit has been reached. 0 entries not shown. Preferences GET http://10.208.137.92/js/v1/External/JSON/sample.json GET http://10.208.137.92/js/v1/External/JSON/sample.json 304 Not Modified 111ms jquery-1.6.2.js (line 7869) readJSON1 alerts [Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}] readJSON2 alerts [Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}] inside parseJSON: alerts [Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}, Object { alertPartnerDefinedInfos=[1], name="100 S.Ct. 1", more...}] Javascript code Code: function populateSearchResults(alert){ var listOfAlertsDiv = document.getElementById('listOfAlertsDiv'); //var x = document.getElementById('rowTable').insertRow(0); //TODO: Replace the above code to remove Table declaration in above HTML. Instead use JQuery scrollbar and populate scroll area with the content below. // Create a new table. Add a row to it and then add the below cell to it. //TODO: Create a div // Create a table // Add the above created div to div1 var rowDiv = document.createElement('div'); rowDiv.className="scroll-content-item"; var rowContentTable = document.createElement('table'); rowContentTable.width="100%"; rowContentTable.border="0"; rowContentTable.cellpadding="0"; rowContentTable.cellspacing="0"; rowContentTable.summary="Row Content Table"; var rowContentTableFirstRow = rowContentTable.insertRow(0); var checkBoxCell = rowContentTableFirstRow.insertCell(0); checkBoxCell.width = "1%"; //x.valign = "top" //var checkBoxCell = x.insertCell(0); //checkBoxCell.width = "1%"; var checkBox = document.createElement('input'); checkBox.type = "checkbox"; checkBox.name = "checbox"; checkBox.value = "true"; checkBoxCell.appendChild(checkBox); var contentCell = rowContentTableFirstRow.insertCell(1); contentCell.width = "99%"; var contentTable = document.createElement('table'); contentTable.style.border = '1'; contentTable.cellPadding = '0'; contentTable.cellSpacing = '0'; contentTable.width = "100%" var titleRow = contentTable.insertRow(0); var titleCell = titleRow.insertCell(0); titleCell.width = "70%"; titleCell.id = "alertTile" var title = document.createElement('a'); title.href = "http://www.google.com"; title.id = "AlertResultNameLink"; titleText = document.createTextNode(alert.name); title.appendChild(titleText); titleCell.appendChild(title); var moveToFolderCell = titleRow.insertCell(1); moveToFolderCell.width = "5%"; moveToFolderCell.id = "moveToFolder"; var moveToFolderCellImage = document.createElement('img'); moveToFolderCellImage.alt = "Move To Folder"; //TODO: Change the hardcoding of the image location to symbolic links moveToFolderCellImage.src = "/js/v1/Alerts/images/co_documentFooterArrowFirst_inactive.png" moveToFolderCellImage.border = 0; moveToFolderCellImage.className = "moveToFolder"; moveToFolderCell.appendChild(moveToFolderCellImage); var editAlertCell = titleRow.insertCell(2); editAlertCell.width = "10%"; var editAlertButton = document.createElement('a'); editAlertButton.href = "http://www.google.com"; editAlertButton.className = "EditAlertButton"; var editAlertButtonImage = document.createElement('img'); editAlertButtonImage.alt = "Edit Alert"; //TODO: Change the hardcoding of the image location to symbolic links editAlertButtonImage.src = "/js/v1/Alerts/images/co_overlayBox_closebutton.png"; editAlertButtonImage.border = 0; editAlertButtonImage.className = "EditAlert"; editAlertButton.appendChild(editAlertButtonImage); var editAlertButtonText = document.createTextNode(' Edit Alert '); editAlertButton.appendChild(editAlertButtonText); //editAlertButton.innerHTML = " Edit Alert " editAlertCell.appendChild(editAlertButton); var alertMetaDataRow = contentTable.insertRow(1); var alertMetaDataCell = alertMetaDataRow.insertCell(0); var alertMetaDataTable = document.createElement('table'); alertMetaDataTable.width = "100%" var alertMetaDataTableRow = alertMetaDataTable.insertRow(0); alertMetaDataTableRow.width = "100%" var lastUpdateCell = alertMetaDataTableRow.insertCell(0); lastUpdateCell.width = "25%" //var lastUpdateCellText = document.createTextNode("Last Update:"); var lastUpdateCellText = document.createTextNode("Last Update: " +alert.lastRunDate); lastUpdateCell.appendChild(lastUpdateCellText); var nextUpdateCell = alertMetaDataTableRow.insertCell(1); nextUpdateCell.width = "25%" var nextUpdateCellText = document.createTextNode("Next Update:"); nextUpdateCell.appendChild(nextUpdateCellText); var clientIdCell = alertMetaDataTableRow.insertCell(2); clientIdCell.width = "50%" var clientIdCellText = document.createTextNode("Client ID: ") clientIdCell.appendChild(clientIdCellText); alertMetaDataCell.appendChild(alertMetaDataTable); var descriptionRow = contentTable.insertRow(2); var descriptionCell = descriptionRow.insertCell(0); var descriptionTitle = document.createTextNode("Description: "); descriptionCell.appendChild(descriptionTitle); var activeDeliveryRow = contentTable.insertRow(3); var activeDeliveryCell = activeDeliveryRow.insertCell(0); var activeDeliveryTitle = document.createTextNode("Active Delivery"); activeDeliveryCell.appendChild(activeDeliveryTitle); var rss1 = document.createElement('img'); rss1.style.border = "0"; rss1.src = "images/rssIcon.png"; rss1.hspace = "4"; activeDeliveryCell.appendChild(rss1); var rss2 = document.createElement('img'); rss2.style.border = "0"; rss2.src = "images/rssIcon.png"; rss2.hspace = "4"; activeDeliveryCell.appendChild(rss2); var rss3 = document.createElement('img'); rss3.style.border = "0"; rss3.src = "images/rssIcon.png"; rss3.hspace = "4"; activeDeliveryCell.appendChild(rss3); var rss4 = document.createElement('img'); rss4.style.border = "0"; rss4.src = "images/rssIcon.png"; rss4.hspace = "4"; activeDeliveryCell.appendChild(rss4); contentCell.appendChild(contentTable); rowDiv.appendChild(rowContentTable); listOfAlertsDiv.appendChild(rowDiv); contentCell.appendChild(document.createElement('br')); contentCell.appendChild(document.createElement('hr')); contentCell.appendChild(document.createElement('br')); } function readJSON(){ var json = ""; //$(document).ready(function(){ $.getJSON("/js/v1/External/JSON/sample.json", function(data){ json = data; console.log("readJSON1"); console.dir(data); }); //}); console.log("readJSON2"); console.dir(json); return json; } function parseJSON(){ var alerts = []; var json = readJSON(); console.log("inside parseJSON:"); console.dir(json); //TODO: Check if JSON is not null. for(var i in json.alerts){ var createdDate = new Date(json.alerts[i].createdDate); var alert = new Cobalt.Alerts.DataTypes.Alert(); var AlertPartnerDefinedInfos = []; alert.name = json.alerts[i].name; alert.lastRunDate = $.format.date(new Date(json.alerts[i].lastRunDate),"MM/dd/yyyy hh:mma"); alerts.push(alert); } //console.log("fillRows: " +alerts.length); return alerts; } $(document).ready(fillRows=function(){ var alerts = parseJSON(); //console.log("fillRows: " +alerts.length); for(i=0;i<alerts.length;i++){ var alert = alerts[i]; populateSearchResults(alert); } }); |