473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.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
Jul 20 '05 #1
1 1352
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" <ja************@hccnet.nl> wrote in message
news:bm**********@news.hccnet.nl...
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

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Cristian | last post by:
Hi all, When I download a file with ftp_nb_get, I'd like to show the elapsed time and so I had insert this javascript function in my php page <SCRIPT> function scrivi(num, num2, num3) {...
4
by: rick | last post by:
The following basic script works fine in firefox by not in IE. Can anyone spot the problem? In IE I can only delete the first line but not the lines created by javascript. Also, look at the HTML...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
2
by: alxasa | last post by:
Hi, I have a setInterval which executes its command every 10 seconds in a infinite loop. I've got something real basic like: var processes=0; function startme(){ if(stopthisloop>1)
2
by: akanialaka | last post by:
Hope I can get some help here... I connect to an SQL database using ASP. I can see the records. I have a small (very basic) function written in Javascript. When I use the MoveNext in the...
1
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript...
30
by: Jeff Bigham | last post by:
So, it appears that Javascript has a recursion limit of about 1000 levels on FF, maybe less/more on other browsers. Should such deep recursion then generally be avoided in Javascript?...
2
by: phpentrylevel | last post by:
hello i am a newbie to Javascript with a in depth background of PHP i have a simple script that replaces missing images when the webpage loads but i just cant get it to validate in JLint as my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.