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> Quote 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] Quote 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? :) Quote 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. Quote 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!!! :-* Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.