What is the difference between “new Number(…)” and “Number(…)” in JavaScript?

In Javascript, one of the reliable ways to convert a string to a number is the Number constructor: var x = Number(’09’); // 9, because it defaults to decimal Inspired by this question, I started wondering — what is the difference between the above and: var x =new Number(’09’); Number certainly looks better, but it … Read more

How do you change an HTML radiobutton selection from Javascript?

I need to select an HTML radiobutton (deselecting any previously selected radiobutton) on my form, from within Javascript. How is this accomplished? Answer If you set the “checked” property to true on one radio button, the other button with the same name is automatically unchecked. Thus, document.getElementById(‘buttonX’).checked = true; will cause “buttonY” to be unchecked … Read more

Complex JavaScript. What called me?

Project I’m working on uses jQuery. I have a series of Ajax calls being made that load() other HTML fragments which in turn load() other fragments. The whole thing is confusing. I didn’t write the code. Is there any tool which will allow me to walk the callstack so I can figure what is calling … Read more

jQuery working out wrong height, due to @font-face

I have a problem with jQuery and @font-face. I need to work out the height of a <div>, which works fine, but then there is a small delay for the fonts to load and as soon as they do, the @font-face fonts were actually bigger than the fallback fonts, so the height is smaller than … Read more

Accessing Django template {{Variable}} from JavaScript

I tried to access django template variable in html page inline javascript, it works fine. But if I include js using <script src=”..> then it dont work. Is this limitation or I’m doing something wrong? I really appreciate your help. Answer The included Javascript isn’t processed by the Django template processor on the server, so … Read more

Pass the value of a SELECT to a Javascript function via the onchange event?

I have a HTML page that contains a search box containing a number of textboxes. The first part of the search box is a SELECT dropdown list that contains a variety of report types. Each report type requires 1 or more of textboxes to be filled in to filter the query results. My goal is … Read more