Click to See Complete Forum and Search --> : pass variables between html docs
domuk
11-08-2003, 09:37 AM
Hi again,
I am trying to pass variables between different html documents.
They may be open or closed when the data is passed. Due to this I assume I will have to store them in a central location and read and write to them depending on which document I am using.
The DATA: number of variables.
V1=1000, V2=2000, VT=V1+V2=3000
(calculation 1 on “date&time”)
V1=2000, V2=2000, VT=V1+V2=4000
(calculation 2 on “date&time”)
I have a calculation html page that calculates say vt and logs v1 & v2. I want the user to press a button to log the current calculation and result (referencing them to say the date and time or some other unique variable) The results can then be viewed at a later time by that user.
I am not sure which way to turn. I think a perhaps a simle database or pass the values to an open excel spreadsheet or maby some form of cooke. Could someone please help guide me in the correct direction and point me at some similar code that I can modify.
I just don’t want the user to cut and paste the results into another open document.
Thanks in advance
olerag
11-08-2003, 10:05 AM
If I'm understanding you correctly, you would like one or
more users to be able to enter data and have this info
retained and, possibly, retrieved at some later runtime
session.
Consequently, you can use Java servlets to fullfill the
HTML portion (making the screens and saving/retrieving
info) that interact with a database.
For a client-server config, the Java class(es) will be parked
in a place designated by your webmaster and you'll
need either a JDBC or ODBC driver to interact with the
database (server-side).
Once all this is customized, passing the parameter values
from one HTML page to another can be performed using
"getParameter" or "getParameterValues" functions provided
with the Java "servlet" package.
For detailed info on all of this, I recommend a visit to a
Java forum (or, www.java.sun.com).
domuk
11-08-2003, 01:35 PM
Hi olerag,
Thanks for your reply. I was hoping that it could be done in Javascript. Is it not possible in javascript?
Could i not do this in a cookie?
Sorry for being a pain, i did not want to learn another language before i have fully learnt javascript.
Thanks in advance,
Dom.
olerag
11-08-2003, 04:01 PM
Well, JS is intended to manipulate HTML pages currently
being viewed. From your thread, you give the impression that
your attempting to retain user input to be brought back at
some later time.
For this, obviously, your left with file i/o or database (which is
really still just file i/o, manipulated by a db engine.
For web-based client/server designs, security must be
maintained consequently servers send the info to one or
more clients. This has nothing to do with JS.
domuk
11-09-2003, 03:36 AM
Thanks again for your response.
It's made things a bit clearer.
In this case, how do I pass variables between HTML documents being viewed and possibly save that data into a cookie for the user to re-access the information?
Also, is it possible to write a script to save a cookie to the A-drive (I know from what you have just told me, JS wouldn't do this so would I need to use PHP or Java?)
Are there any scripts that will do this as I have absolutely NO idea about Java or PHP! (Preferably PHP)
If I were to learn another programming language for web data base file manipulation which one would I choose? How do I go about getting the software for the de-bug/compiling environment? I am assuming PHP is simple, quick to learn and widely used language. However I'm not sure if it does data bases.
Sorry this is a bit of a "mish-mash" question, but you've been very helpful so far!
Thanks again for your help
Dom
olerag
11-09-2003, 05:40 PM
Well, if your considering a server-side web appl:
1. I like Java because it offers complete flexibility but
it is a sophisticated language consequently the effort is
total.
2. If you do decide to implement Java servlets, you
don't need to consider "cookies" as you keep the info
on the server-side (calling a file I/O class, possibly running
RMI (another Java topic)). Also, I don't like programs that
write to my computer.
3. Passing args is the least of your worries but you'll find
that its very easy including arrays. Of course, if you place
the values in HTML form's objects, the page's submit will
pass the values for you automatically.
If you prefer to pass other values, typically a URL, such as
the following would pass "myVal1" and "myVal2".
http://myServer/myClass?myVal1=1&myVal2=2
Java's getParamter("myVal1") method would store the value
in a String variable of the class. To capture array values, the
"getParameterValues() method stores array values, such as
myClass?myVal=1&myVal=2, in a String array.
Hope this helps...
domuk
11-10-2003, 03:32 AM
Thanks again.
I shall look into it.
I am a bit new to the server-side thing I once used a PHP guestbook, however had to change host as he host that i was using would not allow PHP. (granted it was free)
Would i have the same problems with Java?
Thanks in advance,
Dom.
Khalid Ali
11-10-2003, 06:29 AM
Yes,because most of the people would be suing apache webserver,and for Java to be used on server side you will need java(servlet/jsp) enabled web browser(an example of which may be tomcat,JRun etc).
If you need a simple form processing code then use
php/apache because that is most likely available on most of the web hosting companies.
domuk
11-10-2003, 07:59 AM
Thanks Khalid,
Just what i needed to know (learn PHP first for server side file access applications)..