javascript

jQuery Validation Plugin: Packer undefined error?

I'm using the jQuery validation plugin from bassistance.de. It works fine. From <head>: <script type="text/javascript" src="/static/JQuery.js"></script> <script type="text/javascript" src="/static/js-lib/jquery.validate.pack.js"></script> <script type="text/javascript" src="/static/js-lib/jquery.validate.additional-methods.js"></script...

Javascript: Make a static code, dynamic - List of inputs

I have this code, that checks some ids and enable others, the javascript is pretty clear about what it does, but since it corresponds to some specific id ranges, I cant do just a look until it finishes, but I'm looking a way to do this dynamic and save 40 lines of code (or more), since its not the best way. function loopGroup1() { v...

JavaScript-library-based Project Organization

Hello, I'm very new to the JavaScript library world. I have used JS by itself before to create a mini social network but this is the first time I use a JS library and I really don't know how to go about this. I'm planning to use Google Closure and I'm really not sure how I should go about organizing the code. Should I put everything in...

How to have screen revert to BLACK between pages?

0 Hi - I tried out the Background Image Scaling script and with Cybr's update it works like magic. It SCALES the image perfectly. No distortion. BUT, my image isn't "computer friendly". I.e.: Not 1024 X 768 or even close to that. (Heck, my monitor has a wide screen, so it isn't 1024 X 768 either! Is anybody's anymore?) Anyhow, this c...

Is it possible to remove all event handlers of a given element in javascript?

Hi, I would like to remove ALL handlers for a given event type. Let's say I've added twice "onclick event" to a button and now I would like to return back to the original state where no event handler was set to the button. How can I do that? P.S.: I've found removeEventListener (non-IE)/detachEvent (IE) methods but the functions want...

align WMD editor's preview HTML with server-side HTML validation (e.g. no embedded javascript)

There are many SO questions (e.g. here and here) about how to do server-side scrubbing of Markdown produced by the WMD editor to ensure the HTML generated doesn't contain malicious script, like this: <img onload="alert('haha');" src="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png" /> But I didn't find a good way to plug ...

Javascript: Remove checked status from disabled input (already checked)

Im trying to make this function to check an element and if its checked, or not, add or remove respective className. Also, if the element is disabled but is checked, it should un-check it and remove the className('yes') function init() { $(document.body).select('input').each(function(element) { if (!element.checked) { ...

How to use JS to jump to a specific place in a page? Tried scrollIntoView, not working

I have a PHP form for discussions. Each message has its own response button, which is dynamically generated. I'm using javascript in the button to make a response form visible at the bottom of the page, but I can't for the life of me get the page to jump down to the form once it's visible. This is a problem for pages that have a lot of d...

JavaScript Resource Management Design Pattern

As a web developer, a common problem I find myself tackling is waiting for something to load before doing something else. In particular, I often hide (using either display: none; or visibility: hidden; depending on the situation) elements while waiting for a background image or a CSS file to load. Consider this example from Last.FM. The...

Mathematical problem

I have the following function: function getLevel(points) { var level = -1 + Math.sqrt(4 + points/20); // Round down to nearest level return Math.floor(level); } The above function calculates the level of a player based on their points, my problem is that I need a function like this to calculate the points needed for a given lev...

How to animate characters text with html5

How would I animate individual characters of text on a page in HTML5. Like this example in flash. http://www.greensock.com/splittextfield/ ...

How bad is it to embed JavaScript into the body of HTML?

A team that I am working on has gotten into the habit of using <script> tags in random places in the body of our HTML pages. For example: <html> <head></head> <body> <div id="some-div"> <script type="text/javascript">//some javascipt here</script> </div> </body> </html> I had not seen this befor...

Multiple storages using localStorage

Is it possible that the same name used can have many different values stored separately and to be shown in a list? E.g.: function save() { var inputfield = document.getElementById('field').innerHTML; localStorage['justified'] = inputfield; } <input type="text" id="field" onclick="save();" /> Every time someone enters somethi...

Is there a way to programmatically click on a combobox item?

Hi, I've been trying experiments with the following, but so far to no avail: sel = document.getElementById('myComboBox') sel.selectedIndex = 1; sel.options[1].selected = true; sel[1].click(); Thanks for the help! ...

Callback function doesn't work when using getJSON

Hi, This is the code that I am using, When I write the link into the browser (I.E. or Mozilla) it is working like (MyFunc({"memes":[{"source":"http://www.knall......), but when I try to run it as HTML file I have a error in status Bar. what is the problem?. Thanks <head> <style>img{ height: 100px; float: left; }</style> <scri...

document.getElementById().innerHTML for select tag doesn't work in IE

i have the following simple script <input type="button" onclick="document.getElementById('a').innerHTML = '<option>something</option>';"/> <select id="a" style="width: 150px;"> </select> but it doesn't work in IE. could you tell me why? thanks ...

Easiest way to convert json data into objects with methods attached?

What's the quickest and easiest way to convert my json, containing the data of the objects, into actual objects with methods attached? By way of example, I get data for a fruitbowl with an array of fruit objects which in turn contain an array of seeds thus: {"fruitbowl": [{ "name": "apple", "color": "red", "seeds": [] ...

Javascript unable to pass parameters into a property acting as a function

Currently in a simplified form, my code looks like this function AddFileParam(file_id, name, value) { uploadcontrol.AddFileParam(file_id, name, value) } uploadcontrol = new Upload() function Upload() { //logic } Upload.prototype.AddFileParam = function(file_id, name, value) { //logic }; The code is giving me an error as ...

Get Title of selected tab

Is there a way of getting the value of the title of the page from a Google Extension? ...

Morphing content based on window part focus

What I'm trying to achieve is basically have a code that will morph ( move around the page ) based on the part of the window which is currently viewed. Scenario : - actual page height : 2000px - actual screen height( pc, laptop whatever ) : 800px - 1 image of 600px - 3 div's or virtual boxes ( just to prove what I want to do ) Workflow...