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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jack vermeulen

    #1

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

    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.for m1.hgoals.value > document.form1. agoals.value){
    document.form1. hpoints.value = (3)
    document.form1. apoints.value = (0)
    }
    else if(document.for m1.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

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

    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.for m1.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.



    "jack vermeulen" <jack.vermeulen @hccnet.nl> wrote in message
    news:bmtknl$eu6 $1@news.hccnet. nl...[color=blue]
    > Hello,
    >
    > I'm working on a script(for giving points to a soccergame 0, 1 or 3[/color]
    points)[color=blue]
    > 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.for m1.hgoals.value > document.form1. agoals.value){
    > document.form1. hpoints.value = (3)
    > document.form1. apoints.value = (0)
    > }
    > else if(document.for m1.hgoals.value < document.form1. agoals.value){
    > document.form1. hpoints.value = (0)
    > document.form1. apoints.value = (3)
    > }
    >
    >
    >
    > I hope someone can help me.
    >
    > Jack
    >
    >[/color]


    Comment

    Working...