paolinaaaaaaa Posted July 24, 2006 Share Posted July 24, 2006 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"><!-- Beginfunction 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 https://forums.phpfreaks.com/topic/15498-script-works-in-firefox-but-not-in-explorer/ Share on other sites More sharing options...
nogray Posted July 24, 2006 Share Posted July 24, 2006 the "interval" variable is a local variable to the startCalc() function. You need to make it global like this[code]<!-- Beginvar interval = "";[/code] Link to comment https://forums.phpfreaks.com/topic/15498-script-works-in-firefox-but-not-in-explorer/#findComment-62954 Share on other sites More sharing options...
paolinaaaaaaa Posted July 25, 2006 Author Share Posted July 25, 2006 thanks...I tried it but it still doesn't work. Any more suggestions? :) Link to comment https://forums.phpfreaks.com/topic/15498-script-works-in-firefox-but-not-in-explorer/#findComment-63295 Share on other sites More sharing options...
nogray Posted July 25, 2006 Share Posted July 25, 2006 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 https://forums.phpfreaks.com/topic/15498-script-works-in-firefox-but-not-in-explorer/#findComment-63646 Share on other sites More sharing options...
paolinaaaaaaa Posted July 26, 2006 Author Share Posted July 26, 2006 it works now...thanks!!! :-* Link to comment https://forums.phpfreaks.com/topic/15498-script-works-in-firefox-but-not-in-explorer/#findComment-63854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.