homepage Welcome to WebmasterWorld Guest from 54.242.190.171
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Stops Parsing, but no error on lint checkers
twprogrammers



 
Msg#: 4571991 posted 7:05 pm on May 8, 2013 (gmt 0)

I cannot figure out why it stops parsing. I tried javascriptlint.com [javascriptlint.com], no error. I tried jsfiddle.net, no error. Here is my code:


function convert()
{
var box = document.getElementById("box");
var height = document.getElementById("height");
var width = document.getElementById("width");
var w = parseint(document.getElementById("w").value,10);
var h = parseint(document.getElementById("h").value,10);
var d = parseint(document.getElementById("d").value,10);
var dec = parseint(document.getElementById("dec").options[document.getElementById("dec").selectedIndex].value,10);
var units = document.getElementById("units").options[document.getElementById("units").selectedIndex].value;
var y = (d * h)/Math.sqrt(Math.pow(w,2)+Math.pow(h,2));
var x = (w/h)*y;
var n = 0;
if(dec === 0)
{
n = 1;
}
else if(dec == 1)
{
n = 10;
}
else if(dec == 2)
{
n = 100;
}
y = Math.round(y*n)/n;
x = Math.round(x*n)/n;
var hInUnits = y.toString() + " " + units;
var wInUnits = x.toString() + " " + units;
document.getElementById("plain").innerHTML = "<p>Width: " + wInUnits + "<\/p><p>Height: " + hInUnits + "<\/p>";
height.innerHTML = hInUnits;
width.innerHTML = wInUnits;
var m = 0;
if(w <= 9 && h <= 5)
{
m = 100;
}
else
{
m = 10;
}
box.className = "visible";
var boxH = h * m;
var boxW = w * m;
box.style.height = "" + boxH.toString() + "px";
box.style.width = "" + boxW.toString() + "px";
return true;
}


It stops parsing at:
var w = parseint(document.getElementById("w").value,10);

I figured out that by placing
alert("test"); above and below it. When above the alert shows, when below it does not. What am I missing? What am I doing wrong?
Any and all help is appreciated.

 

DrDoc

WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4571991 posted 7:46 pm on May 8, 2013 (gmt 0)

Since you are still relatively new to our forums -- a warm welcome to WebmasterWorld!

A couple quick questions:
Do you still experience this problem if you change parseint to the proper parseInt?
If yes:
Is the w ID unique on the page?
What element is it attached to?

twprogrammers



 
Msg#: 4571991 posted 8:51 pm on May 8, 2013 (gmt 0)

No, yes, and textbox.

Thanks for the correction... I feel stupid now.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved