...

View Full Version : JavaScript Global Variables within a Web Form



kevcox
11-01-2006, 04:26 AM
I'm fairly new to the web development thing so I need a little direction. I'm creating an in-house Tech Ticket System and from the .asp form with an SQL Server I'm wanting to display a confirmation page with the data collected from the form. I assume I would setup some global variables that is setup within the form but how do I establish global variables and/or pass them onto a confirmation page?
Also any suggestions on the programming language I should be using for this? I'm using FrontPage 2003 and have a small amount of knowledge about VB Script and JavaScript but can pick up something else if it is better for this project.
Thank you,

Kevcox

ess
11-01-2006, 09:32 AM
Since you are using a form, and passing information to another page (in this case, confirmation page as you called it), you can always pass data in hidden input fields that is not visible to users.

for example, let say that you want to pass the userID, but you don't want the user to see it. Then you can do the following.


<form method="GET" ....>
<input type="hidden" name="userID" value="value of user id here" />
...other input fields here
</form>

in your confirmation page, you can obtain this value via asp, or any other scripting language you choose to use, and echo it out within <script> tags. here is an example in php, as I am not familiar with ASP.


<?php
$userID = $_GET['userID'];

echo "<script type='text/javascript'>";
echo "var userID = " . $userID;
echo "</script>";
?>

That is it, you should now have userID as a global variable available in both PHP and JavaScript.

As for editors, I think DreamWeaver is very good when it comes to scripting. It supports PHP, ASP, JSP and other languages.

Check out this page (http://www.photoshopsupport.com/dreamweaver/tt/total-training.html), which provides video tutorials for DreamWeaver.

All the best.
:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum