Javascript Question

Hack your OS, customize your GUI, announce great software, and configure, configure, configure...

Javascript Question

Postby SOD » 05/24/07, 1:54 am

So I wrote the following to randomize an object in an array:

Code: Select all
unction quote(title,url,content)
{
this.title=title
this.link=url
this.content=content
}

var quot = new Array()
quot[0] = new quote("Alexis de Tocqueville","www.blah.com","History is a gallery of pictures in which there are few originals and many copies.")
quot[1] = new quote("Rita Mae Brown","www.blah.com","Good judgment comes from experience, and often experience comes from bad judgment.")
quot[2] = new quote("Malcolm Forbes","www.blah.com","Education's purpose is to replace an empty mind with an open one.")
quot[3] = new quote("Herbert Hoover","www.blah.com","About the time we can make the ends meet, somebody moves the ends.")

var mynum = Math.floor(Math.random()*4)

document.write("<h4>"+quot[mynum].content.fontcolor("#336600").fontsize(2)+"<br>"+quot[mynum].title.fontcolor("#000").fontsize(2)+"</h4>")


Question is how do I go about refreshing the array
that is, add new content from xml to the array?
It is better to be here than there - SOD
SOD
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
 
Posts: 5284
Joined: 12/06/01, 12:00 am
Location: here and there

Postby RedRage » 05/24/07, 5:18 pm

don't remember with javascript but other langs...

Code: Select all
function whatEver (putInto,someArray)
{

  var newArray = someArray;

  newArray[] = putInto;

  return newArray;

}


call it like

Code: Select all
 var anArray = function(someValue,xmlArray);

"i think" that will work in javascript. everytime its called it "should" take putInto (the value you want to add to the array) and put it into a new array with the previous values still there. I'm guessing you would use a timer event to pullin the data and for every record that spulled in run the function.

But in all honesty i could be talking out my ass.
Image
RedRage
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
 
Posts: 1541
Joined: 12/04/01, 12:00 am

Postby RedRage » 05/24/07, 5:22 pm

hahaha or just do...

Code: Select all

xmlArray[] = "Some Value";



don't mind me.. been working on some dumbass stuff lately and my iq has fell a bit
Image
RedRage
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
 
Posts: 1541
Joined: 12/04/01, 12:00 am

Postby SOD » 05/25/07, 3:45 am

Thanks Red, I will have to look into it further...
It is better to be here than there - SOD
SOD
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
 
Posts: 5284
Joined: 12/06/01, 12:00 am
Location: here and there


Return to Own The Machine

Who is online

Users browsing this forum: No registered users and 5 guests

cron