New with Javascript: Who like to help me with a loop function?

Discussion in 'Javascript' started by jack vermeulen, Oct 19, 2003.

  1. Hello,

    I'm working on a script(for giving points to a soccergame 0, 1 or 3 points)
    that give a value to a hidden field, i got a function but only works on 1
    field.

    I want that the function loops till all hidden fields are fill in.

    Here's what i got so far:

    function myfunction()
    {

    if (document.form1.hgoals.value == document.form1.agoals.value){
    document.form1.hpoints.value = (1)
    document.form1.apoints.value = (1)
    }
    else if(document.form1.hgoals.value > document.form1.agoals.value){
    document.form1.hpoints.value = (3)
    document.form1.apoints.value = (0)
    }
    else if(document.form1.hgoals.value < document.form1.agoals.value){
    document.form1.hpoints.value = (0)
    document.form1.apoints.value = (3)
    }



    I hope someone can help me.

    Jack
    jack vermeulen, Oct 19, 2003
    #1
    1. Advertising

  2. Hi!

    1.
    Not sure what problem you have,
    but I may use this

    if (document.form1.hgoals.value - document.form1.agoals.value > 0)

    i.e. - compare number with "0"
    This code:

    if(document.form1.hgoals.value > document.form1.agoals.value)

    may compare values as STRINGs, not as NUMBER

    2.
    Also - you may use this syntax: document.forms['form1'].hgoals.value
    It's always working better.

    --
    Sergey.
    http://www.takereal.com/freelance/resume.asp


    "jack vermeulen" <> wrote in message
    news:bmtknl$eu6$...
    > Hello,
    >
    > I'm working on a script(for giving points to a soccergame 0, 1 or 3

    points)
    > that give a value to a hidden field, i got a function but only works on 1
    > field.
    >
    > I want that the function loops till all hidden fields are fill in.
    >
    > Here's what i got so far:
    >
    > function myfunction()
    > {
    >
    > if (document.form1.hgoals.value == document.form1.agoals.value){
    > document.form1.hpoints.value = (1)
    > document.form1.apoints.value = (1)
    > }
    > else if(document.form1.hgoals.value > document.form1.agoals.value){
    > document.form1.hpoints.value = (3)
    > document.form1.apoints.value = (0)
    > }
    > else if(document.form1.hgoals.value < document.form1.agoals.value){
    > document.form1.hpoints.value = (0)
    > document.form1.apoints.value = (3)
    > }
    >
    >
    >
    > I hope someone can help me.
    >
    > Jack
    >
    >
    Sergey I.Grachyov, Oct 19, 2003
    #2
    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. Patrick Kowalzick
    Replies:
    5
    Views:
    470
    Patrick Kowalzick
    Mar 14, 2006
  2. addi
    Replies:
    0
    Views:
    268
  3. Tim::..

    Loop D Loop... Help

    Tim::.., May 26, 2004, in forum: ASP General
    Replies:
    0
    Views:
    125
    Tim::..
    May 26, 2004
  4. Replies:
    2
    Views:
    450
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
  5. Isaac Won
    Replies:
    9
    Views:
    370
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page