...

View Full Version : help with communication between different html pages



Victor
02-06-2004, 03:06 AM
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

glenngv
02-06-2004, 04:39 AM
There are other ways of passing data using javascript. Read this article (http://www.webxpertz.net/faqs/jsfaq/passvars.php). But my question is, how do you maintain the state of the books (available/not available) without using a database?

Victor
02-06-2004, 07:01 AM
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...)

glenngv
02-06-2004, 07:35 AM
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?

Victor
02-06-2004, 08:14 AM
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?

glenngv
02-06-2004, 09:03 AM
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.

Victor
02-09-2004, 12:10 AM
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?

glenngv
02-09-2004, 02:39 AM
Use the combination of IE, ActiveX and HTA (http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp).

With ActiveX, you can connect to a database using javascript. Here is a sample script (http://www.codingforums.com/showthread.php?s=&threadid=31730)

Harry
02-09-2004, 02:44 AM
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.

Willy Duitt
02-09-2004, 04:45 AM
If it is all to be self contained and you are using IE or Explorer you can try using data persistance (http://www.paulspages.co.uk/pcp/154/bpframes.htm).

.....Willy

Victor
02-10-2004, 12:49 AM
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>

Basscyst
02-10-2004, 12:58 AM
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. :o

Basscyst

glenngv
02-10-2004, 01:59 AM
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 (http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm#ODBCDriverForText) for text files.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum