Click to See Complete Forum and Search --> : Variables created in JavaScript


Javium
11-11-2003, 09:22 AM
Hi everybody.:p
I wonder how to pass all the variables created in a .htm to another .htm....
Apparently, when running another .htm all variables are lost.
How to solve this problem?

Robin_R
11-11-2003, 09:42 AM
I'm kind of a beginner in javascript so I don't know if there is a special way to do it with java. But you can always pass the information along using a <form> and php or a query string in the address "index.php?f=123". The last one is good when surfing on a forum but otherwise <form> is better.

Javium
11-11-2003, 10:03 AM
Thank you Robin. As I'm also a novice JS programmer, and know nothing about PHP (yet), I would like to use the <form> but I don't know how to do that. Can you please give an easy example?

The first htm has:

<script language="javascript">
var myvar = 41
</script>

The second htm should enter the variable myvar for use...
If I have 2 or more variables to enter, how is work process?

Robin_R
11-11-2003, 10:08 AM
Sorry, I only know how to do it in php...
then you do like this...

<form action="nextpage.php" method="POST">
<input name="var"
(type="text")/(type="hidden" value="41") <---Choose one of these. They are the easiest.
<input type="submit">
</form>

On nextpage.php:
<script language="javascript">
var myvar = <?php echo $_POST['var'] ?>
</script>
Sorry, but that's all I know....

I would also like to se a solution to how to do this with java