Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    Jan 2021
    Location
    Santa Barbara, CA, USA
    Posts
    144
    Member #
    62344
    Liked
    1 times

    Object-based system

    I'm designing a system that primarily uses objects. Here's the idea so far:
    HTML Code:
    <html>	<head>		<style>			table {border-spacing: 1px}			th, td {padding: 5px}			th {				background-color: darkgrey;				color: white			}			td {background-color: lightgrey}		</style>		<script>			window.onload = function() {				/*					Now generate 'data'.				*/				var data = [					{						name: 'Users',						data: [							{Username: 'Cinder'},							{Username: 'Test'}						]					},					{						name: 'Pages',						data: [							{ID: 1, Parent_ID: 0, Order_ID: 1, Content: 'Hello world'},							{ID: 2, Parent_ID: 0, Order_ID: 2, Content: 'Hello again'}						]					}				];				data.forEach(function(datum) {					var table = document.createElement('table'),						tr = document.createElement('tr'),						th = document.createElement('th'),						initialized = false,						colCount = 0;					th.innerHTML = datum.name;					tr.appendChild(th);					table.appendChild(tr);					datum.data.forEach(function(datum) {						var tr = document.createElement('tr');						if (!initialized) {							var thtr = document.createElement('tr');							table.appendChild(thtr);						}						for (var key in datum) {							if (!initialized) {								var th = document.createElement('th');								th.innerHTML = key;								thtr.appendChild(th);								colCount++;							}							var td = document.createElement('td');							td.innerHTML = datum[key];							tr.appendChild(td);						}						table.appendChild(tr);						initialized = true;					});					th.colSpan = colCount;					document.body.appendChild(table);				});			};		</script>	</head></html>
    I know this is rather simple, I'm programming from the footprint on. The next step is to assign "data" (from the backend). I'm trying to create a generalized system for dealing with, well, everything Let me know your thoughts/ideas.


    Thanks!

  2.  

  3. #2
    Member Cutler's Avatar
    Join Date
    Feb 2021
    Posts
    41
    Member #
    62526
    Liked
    7 times
    The code doesn't look to be formated. I'd recommend putting it in a code pen and linking to it.

    https://codepen.io/
    $1/year Portfolio Hosting with Promo Code: WEBDESIGNFORUMS

    Agency: Marshalled Makers
    Hosting: Marshalled Makers Hosting

  4. #3
    Senior Member
    Join Date
    Jan 2021
    Location
    Santa Barbara, CA, USA
    Posts
    144
    Member #
    62344
    Liked
    1 times


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:29 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com