Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    Nagoya, Japan
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with communication between different html pages

    I'm writing a library program in Javascript, and it is meant to be on a single machine, with no connection any other computer. I have a gbookh object for every book, and a glibraryh array for the whole library(one book on every array position). So if a user is going to borrow a book, I want to send this glibraryh array to the next page (i.e., borrow.html), and then check in this borrow.html if the book is available or not (which is only a property of the gbookh object). Then, change its status (from gavailableh to gnot availableh), and return the glibraryh array.
    And I have no idea about sending this object to the next page. Ifve been reading this tutorial on the main page http://javascriptkit.com/javatutors/send1.shtml but Ifm afraid it didnft help.
    Another solution would be to access this glibraryh array from any page, but then again, I donft know if such a thing is possible.
    Can someone help me with the problem or tell me a web page with this kind of information (foolproof, if possible).
    thx

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts

    Re: help with communication between different html pages

    There are other ways of passing data using javascript. Read this article. But my question is, how do you maintain the state of the books (available/not available) without using a database?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Feb 2004
    Location
    Nagoya, Japan
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well,the idea was to send the array with the library information to the "borrow" page, and then back to the main page.this is a pretty bad solution,but since is only a demo
    program,and there will not be more than 50 or 60 books in the library, i didn't think much about it.besides,i have no idea about how to use a database.
    but maybe is better to use a db after all,since i'm not having much success sending the library array to a different page. which is the best solution to be able to
    consult the information from every different page on the program? (this is my first javascript program,by the way...)

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    But how do you keep the library information updated? Like if someone borrowed a book then some other time another user wants to borrow that same book. How would the library knows that the book has already been borrowed?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Feb 2004
    Location
    Nagoya, Japan
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, if I can send the library array from one page to another, then when a user borrows a book, I intended just to put the library[i].status <- false, and true when he returns it. shouldn't that work?

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You didn't get what I really mean.
    Javascript variables are available only as the page is loaded. If you close the browser (or even reload the page) and open the page again, the data are reset to their original state. You must have some persistent storage such as database or cookie. But the database is the more appropriate storage for your needs. And you need a server-side scripting language (such as PHP, ASP, JSP, etc) to have a database-driven site.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New Coder
    Join Date
    Feb 2004
    Location
    Nagoya, Japan
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the program I'm writting will not be connected to any other machine. There will be no server-client communication.Everything I will need will be inside the computer. In this case, which would be the best option for the storage?

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Use the combination of IE, ActiveX and HTA.

    With ActiveX, you can connect to a database using javascript. Here is a sample script
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #9
    New Coder
    Join Date
    Jul 2003
    Location
    Houston, Texas
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your best bet is to learn PHP programming and use the MySql database. Do a search on net for PHPtriad and download it and install it. You should be able to learn PHP in a couple of weeks. If all your information was to be stored in memory, everything would be lost if the power went off for a second or two.
    Beyond a critical point within a finite space, freedom diminishes as numbers increase. ...The human question is not how many can possibly survive within the system, but what kind of existence is possible for those who do survive."

  • #10
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it is all to be self contained and you are using IE or Explorer you can try using data persistance.

    .....Willy

  • #11
    New Coder
    Join Date
    Feb 2004
    Location
    Nagoya, Japan
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks everyone!

    I think I'll give a try to the ActiveXObject. I've been already testing some functions with it, and It's going pretty fine.

    Now I only need to pass a number to the next page...

    Why is this not working? When I get to the next page and read the data,I only read the string "my_value", not the number 123.

    <script language="javascript">
    var myvalue = 123;

    function nextpage() {
    window.location.href = "main.html?my_value";
    }
    </script>

  • #12
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Use the combination of IE, ActiveX and HTA.

    With ActiveX, you can connect to a database using javascript. Here is a sample script


    __________________
    Glenn
    Awesome. . . .I always use a flat text DB and use the file system object. This . . .this is like a dream come true.

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Originally posted by Victor

    Now I only need to pass a number to the next page...

    Why is this not working? When I get to the next page and read the data,I only read the string "my_value", not the number 123.

    <script language="javascript">
    var myvalue = 123;

    function nextpage() {
    window.location.href = "main.html?my_value";
    }
    </script>
    Because you pass the string "my_value"

    window.location.href = "main.html?" + my_value;


    Originally posted by Basscyst

    Awesome. . . .I always use a flat text DB and use the file system object. This . . .this is like a dream come true.
    FYI, you can make flat text files as DB using ADO.
    Here is the connection string for text files.
    Last edited by glenngv; 02-10-2004 at 02:01 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •