Widget:CJP2: Difference between revisions

Jump to navigation Jump to search
Christopher Popma (talk | contribs)
No edit summary
Christopher Popma (talk | contribs)
No edit summary
Line 10: Line 10:
.always(function (data) {
.always(function (data) {
$.each(data.query.results, function (index, value) {
$.each(data.query.results, function (index, value) {
/*Assign variables the values returned from the function*/
//Assign variables the values returned from the function//
var drugNameFull = value.fulltext;
var drugNameFull = value.fulltext;
var drugNameShort = drugNameLong.split("#")[0];
var drugNameShort = drugNameLong.split("#")[0];
Line 22: Line 22:
var ndc = value.printouts["NDC"];
var ndc = value.printouts["NDC"];
var pillName = value.printouts["Pill Name"];
var pillName = value.printouts["Pill Name"];
/*Create a variable containing the HTML to be appended to the end of the table*/
                        //Find a <table> element with id="resultsTable-body":
var newRow = '<tr> <td>' + drugNameShort + '</td> <td>' + pillImprint + '</td> <td>' + pillDosage + '</td> <td>' + pillIngred + '</td> <td>' + pillColor + '</td> <td>' + pillShape + '</td> <td>' + pillSize + '</td> <td>' + ndc + '</td> <td>' + pillName + '</td> </tr>';
                        var table = document.getElementById("resultsTable-body");
 
                        //Create an empty <tr> element and add it to the 1st position of the table:
                        var row = table.insertRow(index);
 
                        //Insert new cells(<td> elements) into the "new" <tr> element:
                        var cellDrugName = row.insertCell(0);
                        var cellPillImprint = row.insertCell(1);
                        var cellPillDosage = row.insertCell(2);
                        var cellPillIngred = row.insertCell(3);
                        var cellPillColor = row.insertCell(4);
                        var cellPillShape = row.insertCell(5);
                        var cellPillSize = row.insertCell(6);
                        var cellPillSocring = row.insertCell(7);
                        var cellNDC = row.insertCell(8);
                        var cellPillName = row.insertCell(9);
 
                        //Add Values to the cells:
                        cellDrugName.innerHTML = drugNameShort ;
                        cellPillImprint.innerHTML = pillImprint;
                        cellPillDosage.innerHTML = pillDosage;
                        cellPillIngred.innerHTML = pillIngred;
                        cellPillColor.innerHTML = pillColor;
                        cellPillShape.innerHTML = pillShape;
                        cellPillSize.innerHTML = pillSize;
                        cellPillSocring.innerHTML = pillScoring;
                        cellNDC.innerHTML = ndc;
                        cellPillName.innerHTML = pillName;
 
 
 
//Create a variable containing the HTML to be appended to the end of the table//
//var newRow = '<tr> <td>' + drugNameShort + '</td> <td>' + pillImprint + '</td> <td>' + pillDosage + '</td> <td>' + pillIngred + '</td> <td>' + pillColor + '</td> <td>' + pillShape + '</td> <td>' + pillSize + '</td> <td>' + ndc + '</td> <td>' + pillName + '</td> </tr>';
/*Append the new row with the information.*/
/*Append the new row with the information.*/
$('#resultsTable-body').append(newRow);
$('#resultsTable-body').append(newRow);//
});
});
});
});

Revision as of 18:58, 30 May 2014