Can html perform interactively or make decisions?

Discussion in 'HTML' started by senhortomas@hotmail.com, Feb 27, 2006.

  1. Guest

    This is a link to some language translation flash cards I would like to
    emulate:

    http://www.quia.com/jfc/110270.html

    Evidently some calculations or decisions are taking place. The cards
    are randomized and counted. Where does the actual calculation software
    reside? On the host computer? Although I have copied this web site
    off-line to my hard drive, I have not been successful with displaying
    the actual flash cards. What software tools other than html would I
    need? Thnk you.
    , Feb 27, 2006
    #1
    1. Advertising

  2. Guest

    wrote:
    > This is a link to some language translation flash cards I would like to
    > emulate:
    >
    > http://www.quia.com/jfc/110270.html
    >
    > Evidently some calculations or decisions are taking place. The cards
    > are randomized and counted. Where does the actual calculation software
    > reside? On the host computer?


    The example you've given uses Java, client-side.


    > Although I have copied this web site
    > off-line to my hard drive, I have not been successful with displaying
    > the actual flash cards. What software tools other than html would I
    > need?


    JavaScript could do it, so could VBScript, so could Flash, so could
    [insert server-side language here].

    --
    Hywel
    , Feb 27, 2006
    #2
    1. Advertising

  3. Toby Inkster Guest

    senhortomas wrote:

    > Can html perform interactively or make decisions?


    No -- you'd need either a server-side or client-side programming language.

    ECMAScript (a.k.a. Javascript) is really the only client-side scripting
    language in town. Here's an example of something you could do with it:

    <script type="text/javascript">
    function sum ()
    {
    var A = document.getElementById('a');
    var B = document.getElementById('b');
    var C = document.getElementById('c');
    C.value = A.value + B.value;
    }
    </script>
    <div>
    <input id="a"> +
    <input id="b">
    <input type="button" onclick="sum();" value="=">
    <input id="c">
    </div>

    Server-side languages are more reliable in that they don't rely on browser
    support -- the server does the hard work. The draw-back is that for
    the browser has to load a new page to get the results, so to the end user,
    the experience is slower.

    You can potentially use any programming language that you like for
    server-side scripts -- you just need to make sure your server is able to
    run programmes in that language. Common choices are Perl, PHP, VBScript,
    JScript, Java and Python, though C, C++, Shell, Fortran et al can be used
    equally well.

    Here is an example that performs a similar function to the script above,
    but written in PHP:

    <?php
    $A = $_GET['a'];
    $B = $_GET['b'];
    if (isset($A) && isset($B))
    $C = $A + $B;
    ?>
    <form action="<?=$_SERVER['PHP_SELF']?>" method="GET">
    <div>
    <input name="a" value="<?=$A?>"> +
    <input name="b" value="<?=$B?>">
    <input type="submit" value="=">
    <input name="c" value="<?=$C?>">
    </div>
    </form>

    By combining client- and server-side programming, you can have the best of
    both worlds: near-instantaneous results (thanks to client-side), with a
    reliable fall-back.

    Example:

    <?php
    $A = $_GET['a'];
    $B = $_GET['b'];
    if (isset($A) && isset($B))
    $C = $A + $B;
    ?>
    <script type="text/javascript">
    function sum ()
    {
    // If this browser doesn't support
    // getElementById, then fall back to
    // PHP.
    if (!document.getElementById)
    return true;

    // Add the numbers up and display
    // the result.
    var A = document.getElementById('a');
    var B = document.getElementById('b');
    var C = document.getElementById('c');
    C.value = A.value + B.value;

    // Cancel the PHP script.
    return false;
    }
    </script>
    <form onsubmit="return sum();"
    action="<?=$_SERVER['PHP_SELF']?>"
    method="GET">
    <div>
    <input id="a" name="a" value="<?=$A?>"> +
    <input id="b" name="b" value="<?=$B?>">
    <input type="submit" value="=">
    <input id="c" name="c" value="<?=$C?>">
    </div>
    </form>

    (Note: the scripts above are a little simplistic. In real life you'd
    probably want to check that A and B are actual numbers before trying to
    add them together. Adding "12" to "x" will result in "12x" in Javascript,
    but "12" in PHP!)

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Feb 27, 2006
    #3
  4. David Graham Guest

    "Toby Inkster" <> wrote in message
    news:p5n.co.uk...
    > senhortomas wrote:
    >
    > > Can html perform interactively or make decisions?

    >
    > No -- you'd need either a server-side or client-side programming language.
    >
    > ECMAScript (a.k.a. Javascript) is really the only client-side scripting
    > language in town. Here's an example of something you could do with it:
    >
    > <script type="text/javascript">
    > function sum ()
    > {
    > var A = document.getElementById('a');
    > var B = document.getElementById('b');
    > var C = document.getElementById('c');
    > C.value = A.value + B.value;
    > }
    > </script>
    > <div>
    > <input id="a"> +
    > <input id="b">
    > <input type="button" onclick="sum();" value="=">
    > <input id="c">
    > </div>
    >

    Hi Toby
    I just ran the javascript you posted to see it work. When I put in 4 + 3 I
    get an answer of 43 - is that what you intended?
    bye
    David
    David Graham, Feb 27, 2006
    #4
  5. wrote:
    > > http://www.quia.com/jfc/110270.html

    > The example you've given uses Java, client-side.
    > JavaScript could do it, so could VBScript, so could Flash, so could
    > [insert server-side language here].


    Actually to "duplicate" that page you can not use server side
    scripting. Key word being "duplicate" you can make something that
    functions equally as well (or better as it would function on more
    visitors computers)

    Yes, that is nit-picking.
    Travis Newbury, Feb 27, 2006
    #5
  6. Toby Inkster Guest

    David Graham wrote:

    > I just ran the javascript you posted to see it work. When I put in 4 + 3 I
    > get an answer of 43 - is that what you intended?


    Not really -- posted without testing.

    You can use the parseInt() function to convert from a string to an integer.

    e.g.
    var A = parseInt(document.getElementById('a'));

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Feb 27, 2006
    #6
  7. Guest

    Travis Newbury wrote:
    > wrote:
    > > > http://www.quia.com/jfc/110270.html

    > > The example you've given uses Java, client-side.
    > > JavaScript could do it, so could VBScript, so could Flash, so could
    > > [insert server-side language here].

    >
    > Actually to "duplicate" that page you can not use server side
    > scripting. Key word being "duplicate" you can make something that
    > functions equally as well (or better as it would function on more
    > visitors computers)


    You, you're saying that clicking the image couldn't fire a function
    that uses the xmlHTTPRequest to go and get another image, then updates
    the on that's currently on the screen? That would involve server-side
    scripting.

    --
    Hywel
    , Feb 27, 2006
    #7
  8. David Graham Guest

    "Toby Inkster" <> wrote in message
    news:5n.co.uk...
    > David Graham wrote:
    >
    > > I just ran the javascript you posted to see it work. When I put in 4 + 3

    I
    > > get an answer of 43 - is that what you intended?

    >
    > Not really -- posted without testing.
    >
    > You can use the parseInt() function to convert from a string to an

    integer.
    >
    > e.g.
    > var A = parseInt(document.getElementById('a'));
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me ~ http://tobyinkster.co.uk/contact
    >

    Hi Toby
    I altered your code to take into account what you just posted, so it looks
    like this now:
    <script type="text/javascript">
    function sum ()
    {
    //var A = document.getElementById('a');
    var A = parseInt(document.getElementById('a'));
    //var B = document.getElementById('b');
    var B = parseInt(document.getElementById('b'));
    //var C = document.getElementById('c');
    var C = parseInt(document.getElementById('c'));
    C.value = A.value + B.value;
    }
    </script>
    </HEAD>

    <BODY>
    <div>
    <input id="a"> +
    <input id="b">
    <input type="button" onclick="sum();" value="=">
    <input id="c">
    </div>

    When you click the button now nothing happens - no value for C appears on
    the screen!
    Any obvious mistake in my interpretation of your last post please?
    bye
    David
    David Graham, Feb 27, 2006
    #8
  9. wrote:
    > Travis Newbury wrote:
    > > > The example you've given uses Java, client-side.
    > > > JavaScript could do it, so could VBScript, so could Flash, so could
    > > > [insert server-side language here].

    > > Actually to "duplicate" that page you can not use server side
    > > scripting. Key word being "duplicate" you can make something that
    > > functions equally as well (or better as it would function on more
    > > visitors computers)

    > You, you're saying that clicking the image couldn't fire a function
    > that uses the xmlHTTPRequest to go and get another image, then updates
    > the on that's currently on the screen? That would involve server-side
    > scripting.


    Show me a page doing that without and client scripting and I will say
    "good job hywel"
    Travis Newbury, Feb 27, 2006
    #9
  10. Guest

    Travis Newbury wrote:
    > wrote:
    > > Travis Newbury wrote:
    > > > > The example you've given uses Java, client-side.
    > > > > JavaScript could do it, so could VBScript, so could Flash, so could
    > > > > [insert server-side language here].
    > > > Actually to "duplicate" that page you can not use server side
    > > > scripting. Key word being "duplicate" you can make something that
    > > > functions equally as well (or better as it would function on more
    > > > visitors computers)

    > > You, you're saying that clicking the image couldn't fire a function
    > > that uses the xmlHTTPRequest to go and get another image, then updates
    > > the on that's currently on the screen? That would involve server-side
    > > scripting.

    >
    > Show me a page doing that without and client scripting and I will say
    > "good job hywel"


    I didn't say it can't be done *without* client-side scripting. *You*
    said it *cannot* be done using server-side scripting.

    --
    Hywel
    , Feb 27, 2006
    #10
  11. wrote:
    > I didn't say it can't be done *without* client-side scripting. *You*
    > said it *cannot* be done using server-side scripting.


    yea, what ever.
    Travis Newbury, Feb 27, 2006
    #11
  12. In article <>,
    says...
    > wrote:
    > > I didn't say it can't be done *without* client-side scripting. *You*
    > > said it *cannot* be done using server-side scripting.

    >
    > yea, what ever.


    Good come-back. Admit it - you were being a smart arse and got it
    wrong.

    --

    Hywel
    http://kibo.org.uk/
    Hywel Jenkins, Feb 27, 2006
    #12
  13. Toby Inkster Guest

    David Graham wrote:

    > function sum ()
    > {
    > //var A = document.getElementById('a');
    > var A = parseInt(document.getElementById('a'));
    > //var B = document.getElementById('b');
    > var B = parseInt(document.getElementById('b'));
    > //var C = document.getElementById('c');
    > var C = parseInt(document.getElementById('c'));
    > C.value = A.value + B.value;
    > }


    function sum ()
    {
    var A = parseInt(document.getElementById('a').value);
    var B = parseInt(document.getElementById('b').value);
    document.getElementById('c').value = A + B;
    }

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Feb 27, 2006
    #13
  14. trippy Guest

    In article <>,
    Travis Newbury took the hamburger, threw it on the grill, and I said "Oh
    wow"...

    > wrote:
    > > Travis Newbury wrote:
    > > > > The example you've given uses Java, client-side.
    > > > > JavaScript could do it, so could VBScript, so could Flash, so could
    > > > > [insert server-side language here].
    > > > Actually to "duplicate" that page you can not use server side
    > > > scripting. Key word being "duplicate" you can make something that
    > > > functions equally as well (or better as it would function on more
    > > > visitors computers)

    > > You, you're saying that clicking the image couldn't fire a function
    > > that uses the xmlHTTPRequest to go and get another image, then updates
    > > the on that's currently on the screen? That would involve server-side
    > > scripting.

    >
    > Show me a page doing that without and client scripting and I will say
    > "good job hywel"
    >


    http://www.runescape.com

    Well, you'll need one HttpServletRequest for the servlet.

    (.jsp pages get translated to servlets)

    Once you're actually in the doGet/doPost method, you won't need one at
    all. Runescape doesn't require you to refresh the page everytime you
    move or fight something, nor does any other game site that uses an
    applet. In fact, if you hit refresh, you're logged off of the game
    (Runescape) and you have to log in again.

    AFAICT, about the only thing you have to do client side is make sure
    people can find a session again. And have a page.

    Guild Wars would be the only totally client-side game I can think of.
    You actually get all the files you need, as opposed to going to some
    site to play on it. It's ok. Kinda fun actually but it's kinda buggy. I
    don't know if being all client side has anything to do with that.

    --
    trippy
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

    NP: "He-Man Woman Hater" -- Extreme

    "Now, technology's getting better all the time and that's fine,
    but most of the time all you need is a stick of gum, a pocketknife,
    and a smile."

    -- Robert Redford "Spy Game"
    trippy, Feb 28, 2006
    #14
  15. Hywel Jenkins wrote:
    > > > I didn't say it can't be done *without* client-side scripting. *You*
    > > > said it *cannot* be done using server-side scripting.

    > > yea, what ever.

    > Good come-back. Admit it - you were being a smart arse and got it
    > wrong.


    Let's read what we both said.....

    you said:
    The example you've given uses Java, client-side.
    JavaScript could do it, so could VBScript, so could Flash, so could
    [insert server-side language here].

    You imply that each of these can do it by themselves. That is the
    "could do it, so could" part.

    I replied
    Actually to "duplicate" that page you can not use server side
    scripting. Key word being "duplicate" you can make something that
    functions equally as well (or better as it would function on more
    visitors computers)

    This also implys "by it self. Which you agree. Server side scripting
    can not duplicate this by itself. I even stated that if you used only
    server side script and made something with similar functionallity it
    would actually work on more visitors computers.

    So learn to READ before you make an ass of yourself. My "What ever"
    comment was to save you from looking like an ass, but you couldn't let
    it go, and now you look like an ass.



    > > Actually to "duplicate" that page you can not use server side
    > > scripting. Key word being "duplicate" you can make something that
    > > functions equally as well (or better as it would function on more
    > > visitors computers)

    > You, you're saying that clicking the image couldn't fire a function
    > that uses the xmlHTTPRequest to go and get another image, then updates
    > the on that's currently on the screen? That would involve server-side
    > scripting.
    Travis Newbury, Feb 28, 2006
    #15
  16. David Graham Guest

    "Toby Inkster" <> wrote in message
    news:5n.co.uk...
    > David Graham wrote:
    >
    > > function sum ()
    > > {
    > > //var A = document.getElementById('a');
    > > var A = parseInt(document.getElementById('a'));
    > > //var B = document.getElementById('b');
    > > var B = parseInt(document.getElementById('b'));
    > > //var C = document.getElementById('c');
    > > var C = parseInt(document.getElementById('c'));
    > > C.value = A.value + B.value;
    > > }

    >
    > function sum ()
    > {
    > var A = parseInt(document.getElementById('a').value);
    > var B = parseInt(document.getElementById('b').value);
    > document.getElementById('c').value = A + B;
    > }
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me ~ http://tobyinkster.co.uk/contact
    >

    Thanks very much Toby
    bye
    david
    David Graham, Feb 28, 2006
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    40
    Views:
    1,082
    David Thompson
    Aug 26, 2007
  2. terminus
    Replies:
    0
    Views:
    412
    terminus
    Feb 26, 2008
  3. Replies:
    0
    Views:
    91
  4. Replies:
    1
    Views:
    76
    Ivan Marsh
    Mar 28, 2005
  5. tommytx
    Replies:
    5
    Views:
    106
    Billy Bob
    Nov 13, 2005
Loading...

Share This Page