Jump to content


Photo

script works in firefox but not in explorer


  • Please log in to reply
4 replies to this topic

#1 paolinaaaaaaa

paolinaaaaaaa
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 24 July 2006 - 03:06 PM

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!

 
//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>


#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 24 July 2006 - 04:31 PM

the "interval" variable is a local variable to the startCalc() function. You need to make it global like this
<!-- Begin
var interval = "";

NoGray.com


#3 paolinaaaaaaa

paolinaaaaaaa
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 July 2006 - 09:15 AM

thanks...I tried it but it still doesn't work. Any more suggestions?  :)

#4 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 25 July 2006 - 09:26 PM

oh yeah, you are missing the values in your options
<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>
notice how I added "value=#" in the option.

NoGray.com


#5 paolinaaaaaaa

paolinaaaaaaa
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 26 July 2006 - 08:11 AM

it works now...thanks!!! :-*




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users