Question

In: Computer Science

Use a JSON data structure that contains student information (StudentId, FName, LName, Address, City, State, Zip,...

Use a JSON data structure that contains student information (StudentId, FName, LName, Address, City, State, Zip, E-mail, Phone, Major, AdvisorName, AdvisorEmail).

Using the Foreach statement, display all the contents of the JSON data structure into a webpage.

What to turn in:

1. Screenshots: Code, JSON data, Web page showing JSON data in a table - pulled using the Foreach instruction.

Solutions

Expert Solution

1). ANSWER :

GIVENTHAT :

CODE :

datastructure.js

//JSON data structure is a collection of objects
//It consists of name : value pairs
//Names should be in double quotes
//Values with string values should be in double quotes and numbers
//can be specified without quotes
//{ } braces contains collection of name : value pairs i.e., objects
var datastructure = {
           "StudentId" : 1234,
           "FName" : "John",
           "LName" : "Doe",
           "Address" : "Street No.1 Lane 23 Fold",
           "City" : "Cumerics",
           "State" : "Washington",
           "Zip" : 12345,
           "Email" : "[email protected]",
           "phone" : 123456789,
           "Major" : "abcd",
           "AdvisorName" : "Holmes",
           "AdvisorEmail" : "[email protected]" }

data.html

<!DOCTYPE html>
<html>
<head>
<title>JSON Datastructure</title>
<!--Linking datastructure.js file -->
<script src="datastructure.js"></script>
</head>
<body>
   <h1>Data Taken from JSON Data Structure</h1>
<h3 id="result"></h3>
<script>
//Displaying the data in html element
//Getting a html element via its ID
var result = document.getElementById("result");
//Displaying data
//Looping through each object in the datastructure
//Displaying name and values
for( i in datastructure){
   result.innerHTML += i + " : " + datastructure[i] + "<br/>";
}
</script>
</body>
</html>

SCREENSHOTS :

Please see the screenshots of the code for the indentations of the code.

(datastructure.js)

(data.html)

OUTPUT :


Related Solutions

Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20...
Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20 BSK 2244 McJohnson Robert Male 22 2389 Jessica Low Female 20 JPA 4211 Roland Devingo Male 24 4383 Jane Usa Khan Female 21 BKY 4450 Elaine Fong Female 20 JPA CLUB ClubID CName Founded Budget BKY Bakery Club 2010 2546 PDC Photomedia and Design 2005 1345 JPA Japanese Anime 2009 3453 BSK Basketball 2011 6744 If the database administrator in the University has turned...
Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20...
Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20 BSK 2244 McJohnson Robert Male 22 2389 Jessica Low Female 20 JPA 4211 Roland Devingo Male 24 4383 Jane Usa Khan Female 21 BKY 4450 Elaine Fong Female 20 JPA CLUB ClubID CName Founded Budget BKY Bakery Club 2010 2546 PDC Photomedia and Design 2005 1345 JPA Japanese Anime 2009 3453 BSK Basketball 2011 6744 What is the value returned by this SQL statement?...
Database Normalize the relations to BCNF: Member- (MemID, dateJoined, firstName, lastName, street, city, state, zip, areaCode,...
Database Normalize the relations to BCNF: Member- (MemID, dateJoined, firstName, lastName, street, city, state, zip, areaCode, phoneNumber, currentOfficeHeld) Play- (title, author, numberOfActs, setChanges) Sponsor- (sponID, name, street, city, state, zip, areaCode, phoneNumber) Subscriber- (subID, firstName, lastName, street, city, state, zip, areaCode, phoneNumber) Production- (prodyear, seasonStartDate, seasonEndDate, title) Performance – (perfyear,perfdate, time, seasonStartDate) TicketSale- (saleID, saleDate, totalAmount, perfyear, perfdate,subID) DuesPayment- (MemID, duesYear, amount, datePaid) Donation – (sponID, donationDate, donationType, donationValue, prodYear, seasonStartDate) Ticket- (saleID, seatLocation, price, type) Member - Production-(MemID, prodYear,...
Use the data in the Mod8-2Data file to answer the following questions. The data contains information...
Use the data in the Mod8-2Data file to answer the following questions. The data contains information from a car seat manufacturer on the age of machine (in months) and the cost of repairs (in 10s of $). Run the regression in Minitab and show the regression line on a scatter plot. Assume a level of significance of 5%. Age Repairs10 110 32.767 113 37.668 114 39.252 134 44.314 93 34.262 141 47.616 115 32.474 115 33.898 115 43.345 142 52.637...
SQL statmen: List the first name, the last name, the address, the city, the state, the...
SQL statmen: List the first name, the last name, the address, the city, the state, the branchNo, and the email of agents working in the branch B005 and having email addresses ending with extensions different from .com.
The crab data set contains information on the number of "satellites" per female crab. Use a...
The crab data set contains information on the number of "satellites" per female crab. Use a Bayesian model to infer the Poisson parameter. a.  Write the likelihood function. b. Derive the posterior distribution using a Gamma prior w/ rate=20 & shape=3 c. Provide the posterior mean, posterior SD and 95 and 99% posterior credibility region (hint: you can use qgamma). d. Plot the prior and posterior distribution of lambda, in the same plot. mean = 2.919075 variance = 9.912018 n =...
Create a C structure which stores information about a student. Each student should be represented by...
Create a C structure which stores information about a student. Each student should be represented by a student ID (integer), first name, last name, day, month and year of birth, and program code (string). Write a C program which creates an array of 100 of these structures, then prompts the user to enter data from the keyboard to fill the array. If an ID of 0 is entered, data entry should finish, and the list of students should be printed...
The Excel file: OfficeEnergy.xlsx contains information recorded on a sample of 40 of the company’s city...
The Excel file: OfficeEnergy.xlsx contains information recorded on a sample of 40 of the company’s city branches. The file contains the amount of renewable energy (kWh) consumed in the previous year and the size (square metres) of each branch. Download these data and fit a linear regression model for predicting RenewableEnergy (Y) from Size (X). Use your Excel output, and any other information provided, to answer the following questions. For each question, either choose the most correct option, or type...
C++ programming question class Address { public: Address(const std::string& street, const std::string& city, const std::string& state,...
C++ programming question class Address { public: Address(const std::string& street, const std::string& city, const std::string& state, const std::string& zip) : StreetNumber(street), CityName(city), StateName(state), ZipCode(zip) {} std::string GetStreetNumber() const { return StreetNumber; } void SetStreetNumber(const std::string& street) { StreetNumber = street; } std::string GetCity() const { return CityName; } void SetCity(const std::string& city) { CityName = city; } std::string GetState() const { return StateName; } void SetState(const std::string& state) { StateName = state; } std::string GetZipCode() const { return ZipCode; }...
State a data structure that is suitable for storing (i) the words in a dictionary to...
State a data structure that is suitable for storing (i) the words in a dictionary to facilitate searching (ii) the set of folders you have in your computer Explain your choices.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT