/    Sign up×
Community /Pin to ProfileBookmark

Setting Variables to values of array

I am interested in taking the results of an Array and assigning variables to them. The code below highlighted in red populates an HTML table with the results of an array for two properties…. one is properties.name, and the other is properties.value….. i would like to have variables for these resulting values so i can use them in different ways.

For example, there are two polygons, one has the properties of size=12, color=red, and sides=4

the second box has properties of size=25, color=blue, sides=8 and name=octogon

When the code runs the array it merely checks each polygon for the number of properties and lists them into an HTML table….

[B]HTML TABLE POLYGON 1[/B]
[I]Name[/I] [I]Value[/I]
Size 12
Color Red
Sides 4

[B]HTML TABLE POLYGON 2[/B]
[I]Name[/I] [I]Value[/I]
Size 25
Color Blue
Sides 8
Name Octogon

I would like to create variables for each of those values so that i can utilize them in my own expressions…. i.e.

I could use HTML to write “This Polygon has a size of var1=[i][COLOR=Green]12[/COLOR][/I] and its color is var2=[i][COLOR=Green]Blue[/COLOR][/i]. Because it has var3=[i][COLOR=Green]8[/COLOR][/i] sides it is an var4=[i][COLOR=Green]Octogon[/COLOR][/i]!

resulting in the text “This polygon has a size of 12 and its color is blue. Because it has 8 sides it is an octogon.

[code=php]
function SetProperties(count, properties) {
var code;
propCount = count;
if(count != 1)
{
var text;
if(count == 0)
text = “__#PROPERTIESNONE#__”;
else
text = GetMainFrame().FormatMessage(“__#PROPERTIESITEMSEL#__”, new Array(count, “unused”));
code = ‘<table id=”Grid” cellspacing=0 cellpadding=0 border=0><tr><td class=”Info” align=”center”>’ + text + ‘</td></tr></table>’;
}
else
{
code = ‘<table id=”Grid” cellspacing=0 cellpadding=0 border=0><tr class=”Header”><td id=”Name” class=”Name” width=65><span style=”font-family: __#@font#__; font-size: __#@fontsize#__;”>&nbsp;__#PROPERTIESNAME#__</span></td><td class=”CellSplitter” width=1 onmousedown=”StartResizing()”></td><td class=”Value”><span style=”font-family: __#@font#__; font-size: __#@fontsize#__;”>&nbsp;__#PROPERTIESVALUE#__</span></td></tr>’;

for(var i=0; i < properties.length; i++)
{
[COLOR=DarkRed]code += ‘<tr class=”GridCell”><td><span style=”font-family: __#@font#__; font-size: __#@fontsize#__;”>&nbsp;’ + properties[i].name + ‘</span></td><td></td><td><span style=”font-family: __#@font#__; font-size: __#@fontsize#__;”>’ + properties[i].value + ‘</span></td></tr>'[/COLOR];
}

code += ‘</table>’;
}

var content = document.getElementById(“Content”);
content.innerHTML = code; //SAFARI
OnResizeGrid();[/code]

I appreciate any help with this, it seems im sure of what i want to do, just not of how to execute it.

Thank You
Chris

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@cjbeck71081authorSep 14.2006 — aparently the coding of the dark red didnt work, so just look for the code inside the [COLOR=DarkRed] tags... thanks
×

Success!

Help @cjbeck71081 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...