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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript Global Variables within a Web Form

    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

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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.

    PHP Code:
    <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 Code:
    <?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, which provides video tutorials for DreamWeaver.

    All the best.


  •  

    Posting Permissions

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