Skip to content

Tag: javascript

HTML5 – passing Canvas between files

I have two html files, say 1.html and 2.html with 1.js and 2.js referenced javascripts. In 1.html I have a Canvas object with drag and drop functionality, so that i use drawImage method for adding additional images to the canvas. When I am finished with adding images on 1.html, i save the canvas to the localS…

Javascript Page Load Total

I’ve created a form that is used to calculate monthly expenses. The problem I’m having is on the last page I’m gathering information from previous pages (session to data) that auto fills the fields on the last page. I’ve created a Javascript that is suppose to subtract the five fields …

Change jquery ui datepicker programmatically

I’ve got a jquery ui datepicker on my page. It’s linked to a span not an input. It’s currently tweeked to select a week at a time. I’ve also got two buttons on my page ‘Previous Week’ and ‘Next Week’. I want the buttons to control what’s selected by the da…

How to swap DOM child nodes in JavaScript?

What is the easiest way to swap the order of child nodes? For example I want childNode[3] to be childNode[4] and vice-versa. Answer There is no need for cloning. You can just move one node before the other. The .insertBefore() method will take it from its current location and insert it somewhere else (thus mo…

Disable scrolling on “

Is it possible to disable the scroll wheel changing the number in an input number field? I’ve messed with webkit-specific CSS to remove the spinner but I’d like to get rid of this behavior altogether. I like using type=number since it brings up a nice keyboard on iOS. Answer Prevent the default be…

Regexp Matching Hex Color Syntax (and Shorten form)

Well, I’m pretty new on regex and in particular on JavaScript regexp. I’m looking for making a regexp that match the hex color syntax (like #34ffa6) Then I looked at the w3school page: Javascript RegExp Object Then that’s my regexp: It seems to work but, if I want it to match also the &#8220…

How to use typed variables in javascript?

Is there any way to use typed variables in javascript? Like integer, string, float… Answer JavaScript variables are not typed. JavaScript values are, though. The same variable can change (be assigned a new value), for example, from uninitialized to number to boolean to string (not that you’d want …