By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,391 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,391 IT Pros & Developers. It's quick & easy.

Weight converter script inserted in websurvey software works in firefox but not in internet explorer

P: n/a
I am designing a web survey using surveymonkey.com and discovered I
could use javascript to modify their standard question formats much
the same as can be done in myspace.

I used this feature to insert a weight converter I found into my
survey. Unfortunately this script works fine in firefox v.2 but does
not cooperate with the surveymonkey software when used with internet
explorer v.6. In IE, the script makes it so that I am unable to skip
the pages using the usual "next" button.

Why wont the script won't work properly in both browsers? Is there a
simple solution? I paste the script below.

Many thanks,

Graham
<SCRIPT LANGUAGE="JavaScript">
<!-- all mult -->
function GetNumber1(form) {
var sNumber = parseFloat(stripBad(form.txtNumber.value));
var pw3 = parseFloat(form.txtNumbe2.value);
if (isNaN(sNumber)) sNumber = 0;
sNumber = sNumber*pw3
sNumber = gesult(sNumber)
form.txtResult.value= sNumber}
<!-- all divide -->
function GetNumber1b(form) {
var sNumber = parseFloat(stripBad(form.txtNumber.value));
var pw3 = parseFloat(form.txtNumbe2.value);
if (isNaN(sNumber)) sNumber = 0;
sNumber = sNumber/pw3
sNumber = gesult(sNumber)
form.txtResult.value= sNumber}
<!-- all mult -->
function GetNumber2(form) {
var sNumber = parseFloat(stripBad(form.txtNumber.value));
var pw3 = parseFloat(form.txtNumbe2.value)
var ml3 = parseFloat(form.txtNumbe3.value)
var cNum2 = 0
cNum2 = pw3*ml3
sNumber = sNumber*cNum2
sNumber = gesult(sNumber)
form.txtResult.value= sNumber}
<!-- all divide -->
function GetNumber2b(form) {
var sNumber = parseFloat(stripBad(form.txtNumber.value));
var pw3 = parseFloat(form.txtNumbe2.value)
var ml3 = parseFloat(form.txtNumbe3.value)
var cNum2 = 0
cNum2 = pw3*ml3
sNumber = sNumber/cNum2
sNumber = gesult(sNumber)
form.txtResult.value= sNumber}
function GetNumber22(form) {
var sAve = 0
var pw3 = parseFloat(stripBad(form.txtNumber.value));
var ml3 = parseFloat(stripBad(form.txtNumbe2.value));
if (isNaN(pw3)) pw3 = 0;
if (isNaN(ml3)) ml3 = 0;
sAve = (pw3*14) + ml3
sAve = gesult(sAve)
form.txtResult.value = sAve + " pounds" }
function GetNumber33(form) {
var sAve = 0
var pw3 = parseFloat(stripBad(form.txtNumber.value));
var md4 = 0
var lb4 = 0
md4 = pw3 % 14
lb4 = (pw3 - md4)/14
sAve = md4
sAve = gesult(sAve)
lb4 = comma(lb4)
form.txtResult.value = lb4 + " stone " + sAve + " pounds"

}
function GetNumber44(form) {
var sAve = 0
var pw3 = parseFloat(stripBad(form.txtNumber.value));
var ml3 = parseFloat(stripBad(form.txtNumbe2.value));
if (isNaN(pw3)) pw3 = 0;
if (isNaN(ml3)) ml3 = 0;
sAve = (pw3*14) + ml3
sAve = sAve * 0.45359237
sAve = gesult(sAve)
form.txtResult.value = sAve }
function stripBad(string) {
for (var i=0, output='', valid="eE-0123456789."; i<string.length;
i
++)
if (valid.indexOf(string.charAt(i)) != -1)
output += string.charAt(i)
return output;
}
function gesult(ff){

if (Number.prototype.toFixed) {
ff = ff.toFixed(2);
ff = parseFloat(ff);
}
else {
var leftSide = Math.floor(ff);
var rightSide = ff - leftSide;
ff = leftSide + Math.round(rightSide *1e+14)/1e+14;
}
return comma(ff);

}
function comma(num) {
var n = Math.floor(num);
var myNum = num + "";
var myDec = ""

if (myNum.indexOf('.',0) -1){
myDec = myNum.substring(myNum.indexOf('.',0),myNum.length) ;
}
var arr=new Array('0'), i=0;
while (n>0)
{arr[i]=''+n%1000; n=Math.floor(n/1000); i++;}
arr=arr.reverse();
for (var i in arr) if (i>0)
while (arr[i].length<3) arr[i]='0'+arr[i];
return arr.join() + myDec;

}
</SCRIPT>

</HEAD>
<a name = "sptokg"><H2</H2></a>
<H5>*N.B. If you know your highest weight in stones and pounds,
please
convert this to kg and enter the value in the box above</H5<p>
<FORM>
Enter stones: <INPUT TYPE="text" NAME="txtNumber" SIZE=3<B>and</B>
pounds: <INPUT TYPE="text" NAME="txtNumbe2" SIZE=3>
<INPUT TYPE="button" VALUE="Convert to Kg" class="b2t"
onclick="GetNumber44(this.form)" <INPUT TYPE="text"
NAME="txtResult" SIZE=3kg
<input type="reset" class="b3t">
</FORM>
<BR>

Jun 26 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
gray_slp wrote:
>
Why wont the script won't work properly in both browsers?
Why don't you ask in a JavaScript newsgroup? Or if the problem is
limited to IE, ask Microsoft what's wrong with their products.

comp.lang.javascript
microsoft.public.something-about-IE

--
Berg
Jun 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.