Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    1
    Member #
    21151
    Hi, I'm relatively new to web programming and i'm completely new to these forums (hi).

    I'm looking to be able to do something specific for an HTML page. What I want to be able to do is this:

    - have 2 variables in the address bar on the browser
    - be able to display the value of these variables throughout an HTML page

    eg.

    in address bar something like this www.website.com/page.htmlvar1="peanuts";var2=Butter"

    On the webpage something like this

    My favorite foods are: Peanuts and Butter

    (the 'Peanuts' and 'butter' terms are called from the address bar).

    If I change var1 and var2 it should be reflected in the text. If anyone could help me out or point me in the right direction, that would be amazing!


    Thanks !

  2.  

  3. #2
    Junior Member Azmisov's Avatar
    Join Date
    Feb 2010
    Location
    Iceland
    Posts
    6
    Member #
    21257
    I would probably use them as get variables. If you're familiar with php coding you can access url variables with the $_GET[var_name] command. To pass variables to a page, link to the page like so:

    http://www.google.com/somepage.html?foo=bar

    Variable foo would then be equal to bar. To send multiple variables, simply separate them with an & symbol. I don't know if xml or perl have an equivalent $_GET[] method. For me, I would just use php. It isn't actually as hard as it sounds, especially if all you need is to get variables.

    Simple example (somepage.php):
    PHP Code:
    <html>
    ...
    <div id='contents'>

    <?php
    $var1 
    $_GET['var1'];
    $var2 $_GET['var2'];
    echo 
    "My favorite foods are:".$var1."and".$var2
    ?>

    </div>
    ...
    </html>
    Of course, for any server scripting language, you'll need to install a localhost, which isn't that hard. I'm using XAMPP right now.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:15 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com