ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 9th, 2010, 12:25 AM
IceAngel IceAngel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 3 IceAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 8 sec
Reputation Power: 0
Date Array Content Display Issue Complicated

Hi this is my first post and I'm quite stuck if I'm honest and I'm relatively new to ASP that being said I am not looking for a simple solution as any complexities will aid in my learning process

Using Jscript in my ASP

Situation:
I have a 2 dimensional array that needs to be printed out into a table.

Array structure:
array[id][monthNumber] = value
My id does not start at 0(it can tho) the first id is in fact 15 monthNumber can be anything within a 4 month period so it can be 4 - 7 or 11 - 2. Value is just a number

Eg array elements:
array[15][8] = 19
array[15][9] = 52
array[15][10] = 14
array[15][11] = 98

array[20][8] = 125
array[20][9] = 254
array[20][10] = 7
array[20][11] = 9

Problem:
I need to display this information like this
Code:
<table border="1" cellpadding="2" cellspacing="0">
		<tr>
			<td>ID</td>
			<td>August</td>
			<td>September</td>
			<td>October</td>
			<td>November</td>
		</tr>
		<tr>
			<td>15</td>
			<td>19</td>
			<td>52</td>
			<td>14</td>
			<td>98</td>
		</tr>
		<tr>
			<td>20</td>
			<td>125</td>
			<td>254</td>
			<td>7</td>
			<td>9</td>
		</tr>
	</table>

As you can see with the IDs 20 follows 15 so there can be undefined elements. I do have an array with month names in to display the appropriate month name based on the monthNumber element of my array
Code:
var months = new Array();
months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");


As I said before the month period can vary from 1 month to a 4 month period

Oh and the table needs to be produced server side

Will appreciate any solutions

Reply With Quote
  #2  
Old November 9th, 2010, 07:34 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,237 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 50 m 19 sec
Reputation Power: 4445
Quote:
Using Jscript in my ASP
Well, I won't be able to help much then, sorry.

In general you'd construct a loop that will iterate through your array, and at each node your code will generate the appropriate html to get sent to the browser for that node.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old November 9th, 2010, 11:51 PM
IceAngel IceAngel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 3 IceAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 8 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
Well, I won't be able to help much then, sorry.

In general you'd construct a loop that will iterate through your array, and at each node your code will generate the appropriate html to get sent to the browser for that node.


You could write it in VBScript or any other language I can always switch it to JScript I've tried dozens of loop things and I'm getting no where:-(

Reply With Quote
  #4  
Old November 12th, 2010, 05:12 AM
IceAngel IceAngel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 3 IceAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 8 sec
Reputation Power: 0
Solved It :-)

Code:
var output = displayArray(detailArray, drStart, drEnd, nameArray);

function displayArray(chat, start, end, name){
	var table = ""
	table = "<table border=1 cellpadding=2 cellspacing=0 width=550 id=dis><tr bgcolor=#8c929c><td style='color: #FFF;'><b>User</b></td>"
	
	if((start >=10)&&(end >= 1)&&(end <= 4)){
		temp = 13
		for (x = start; x <= temp; x++){
			if (x == 13){
				temp = end
				x = 1 
			}
			table += "<td align=center style='color: #FFF;'><b>" + months[x - 1] + "</b></td>"
		}
	}else{
		for (x = start; x <= end; x++){
			table += "<td align=center style='color: #FFF;'><b>" + months[x - 1] + "</b></td>"
		}
	}
	
	table += "</tr>"
	
	for (i = 1; i < chat.length; i++){
		if (typeof(chat[i]) != "undefined"){
			table += "</tr><tr><td>" + name[i] + "</td>"
			if((start >=10)&&(end >= 1)&&(end <= 4)){
				temp = 13
				for (x = start; x <= temp; x++){
					if (x == 13){
						temp = end
						x = 1 
					}
					if (typeof(chat[i][x]) != "undefined"){ 
						table += "<td>" + chat[i][x] + "</td>"
					}else{
						table += "<td>&nbsp;</td>"
					}
				}
			}else{
				for (x = start; x <= end; x++){
					if (typeof(chat[i][x]) != "undefined"){ 
						table += "<td>" + chat[i][x] + "</td>"
					}else{
						table += "<td>&nbsp;</td>"
					}
				}
			}
		}
	}
	
	table += "</tr></table>"
	return table
}

function dateRange(sDate, eDate){
	tempS = new Date(sDate);
	tempE = new Date(eDate);
	
	drStart = tempS.getMonth() + 1;
	drEnd = tempE.getMonth() + 1;
}

Reply With Quote
  #5  
Old November 12th, 2010, 08:55 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,237 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 50 m 19 sec
Reputation Power: 4445
Thank you for posting your solution!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Date Array Content Display Issue Complicated

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap