Jump to content

question


Recommended Posts

SOLVED-I put this on the backburner, possibly gone forever it was just a program I was thinking about building in javascript, creating a big database(in javascript arrays) and then calling them through a text field to retrieve all the information, I don't want to reveal the idea, but for now I have put it on the side, so problem solved basically.I am building a small database with javascript, for recalling information in a mini-program, what I am trying to do, well I don't want to go into all that, What I want to ask is there a way, because I have to put in all the information, is there a way for me to paste information into a document, then with javascript someone automatically turn all the bits of information into an array.because I am creating about 7 arrays, and wanting them all the be associative arrays pointing to the same keys, for instanceKey 1-has 10 different arrays hooked to it and if I call that 1 then all the information comes for instanceArray 1[1] baboon[2]catarray 2[1] hairy[2] 4 legsarray 3[1]stupid[2]2 legsIt's not what an array looks like but you get the point, if that 1 is called then it pulls hte information saying baboon, hairy, and stupid.If I was to use the variable baboon instead of the key selector it still calls all the information, I am wanting to be able to change a lot of information into an array without having to type it all out, then I can just pretty it up, and put in the information and create another array, because javascript automatically indexes them at 0 and above, I will already have the key indexes set, and the arrays will still be callable by those keys.Any advice would be appreciated thanks.

Link to comment
Share on other sites

Yeah javascript cannot write to or read from text files, that's done by asp/php etc.I think you are talking about 2d arrays, i have one kicking about*goes in search

Link to comment
Share on other sites

But it even might, if you'd have a script element in the html source, with a src to a txt file, but that may not work due to the fact the browser would expect a certain mimetype :)So no I don't think in any other way javascript would be able to read files, let alone writing them :)What about cookies? :)

Link to comment
Share on other sites

if that 1 is called then it pulls hte information saying baboon, hairy, and stupid.
Here's an example of what your 2d array could look like/work.
<head><script>function get_selected(){var game = new Array();game[0] = new Array( "Baboob" , "Cat" );game[1] = new Array( "Hairy" , "4 Legs" );game[2] = new Array( "Stupid" , "2 Legs" );txt="";txt+=game[0][0];txt+=" ";txt+=game[1][0];txt+=" ";txt+=game[2][0];document.getElementById('content').innerHTML=txt;}</script></head><body onload="get_selected()"><div id="content"></div></body>

Link to comment
Share on other sites

Actually there is a way to do what you're asking but it might be more work than you're up for. But it's XML. javascript can import XML files and read their document tree (though it can't write them so forget a dynamically updatable database) and all the information therein.What you seem to be trying to do with the arrays is something like this:

var arr = [["babooon","cat"],["hairy","4 legs"],["stupid", "2 legs"]];function select(animal){     var text = '';     for(var i=0; i<arr.length; ++i)        if(arr[i]==animal)            for(var j=i+1; j<arr.length; ++j)                text += arr[j[i] + " ";    document.getElementById("container").innerHTML = text;}<body onload="select('baboon')">    <div id="container"></div></body>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...