Jump to content

script works in firefox but not in explorer


paolinaaaaaaa

Recommended Posts

Hi everyone I adapted this little script to make a dynamic sum of values inserted in a list box. However I can only get it to work in firefox but not in explorer. Can anyone tell me why? thanx!

[hr]
//in the head of my document:

<script type ="text/javascript">
<!-- Begin
function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.form.comm.value;
  two = document.form.cost.value;
  three = document.form.hres.value;
  four = document.form.qual.value;
  five = document.form.scop.value;
  six = document.form.time.value;
  document.form.total.value = (one * one) + (two * two) + (three * three) + (four * four) + (five * five) + (six * six);
 
  }
function stopCalc(){
  clearInterval(interval);
}
//  End -->
</script>

//in the body

<select name='comm' size ='1' onFocus="startCalc();" onBlur="stopCalc();">
<option selected='selected'>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name='cost' size ='1' onFocus="startCalc();" onBlur="stopCalc();">
<option selected='selected'>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name='hres' size ='1' onFocus="startCalc();" onBlur="stopCalc();">
<option selected='selected'>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name='qual' size ='1' onFocus="startCalc();" onBlur="stopCalc();">
<option selected='selected'>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name='scop' size ='1' onFocus="startCalc();" onBlur="stopCalc();">
<option selected='selected'>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name='time' size ='1' onFocus="startCalc();" onBlur="stopCalc();">
<option selected='selected'>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
Link to comment
Share on other sites

oh yeah, you are missing the values in your options
[code]
<option selected='selected' value=0>0</option>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
[/code]
notice how I added "value=#" in the option.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.