javascript

Javascript array.clear() is not a function?

I'm trying to empty an array containing my drawn coordinates when a button "clear" is pressed. When I call drawnDivs.clear(), I get an error that it is not a function. drawnDivs is certainly an array, and I have firebug console.logs printing things out. It's hosted here. ...

JavaScript: lexical closure or something else?

Consider this script: function Obj(prop) { this.prop = prop; } var NS = { strings: ['first','second','third'], objs: [], f1: function() { for (s in this.strings) { var obj = new Obj(this.strings[s]); obj.f2 = function() { alert(obj.prop); } this.obj...

How to pre-populate check box on jsp

I want to pre populate check boxes on jsp. I have following code on my Mycheckbox.jsp Code MyDTO [] dtoArr = Context.getParameter("PREFdtoSettings"); <%=dtoArr.length%> is 6; dtoArr[i].getId(); gives me the unique ID; In above code am setting PREFdtoSettings parameter in request context in handler class There are almost 100 checkbo...

Prototype Ajax.Autocompleter in dynamically added HTML does not work

Hey, this is the first time I've actually finished writing up a question without SO giving me the answer in the process. :) I've got a nested form (along the lines of Ryan Bates' Railscast tutorial on the topic) which allows users to dynamically add additional fields for adding/removing nested models using Prototype-based javascript. Th...

Finding max value in multidimensional JSON array

Hi all! I'm looking for a really quick, clean and efficient way to get the max "y" value in the following JSON slice: [{"x":"8/11/2009","y":0.026572007},{"x":"8/12/2009","y":0.025057454},{"x":"8/13/2009","y":0.024530916},{"x":"8/14/2009","y":0.031004457}] Is a for-loop the only way to go about it? I'm keen on somehow using Math.max.....

How to read JSONObject in dojo, where JSONObject is created in JSP?

How to read JSONObject in dojo? I have a JSONObject in my jsp. JSONObject myJSONObj = new JSONObject(); How can I read this myJSONObj in my dojo or *.js file, in 'onload function'. ...

Firefox thinks form is not defined, but IE and Chrome do.

I'm trying to get the value of a drop-down menu selection. Here's my XHTML: <form action="(EmptyReference!)" method="get" name="myForm" id="myForm" onsubmit="myValidation(this)"> <fieldset> <select name="mySelect" id="mySelect"> <option value="o1" selected="selected">Option 1</option> <option valu...

js error "_ci has no propeties" in firefox

I tried to implement a calender control into my web app. It works find in IE, but got error "_ci has no propeties" when running in firefox. document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>'); var __ci = window.frames['__calen...

JS: innerHTML and DOM aren't cooperating

I've noticed a funny behavior and was wondering if anybody could shed some light on the reason. It breaks down like this: I've added a div and a button using Javascript's `appendChild'. I add an onclick handler to the button, works fine I add-assign the innerHTML of the div to add some more content Button onclick stops working altoge...

Websocket session between two users

Greets to all! I want to create private messaging based on websockets. It is possible to implement session between two users using websockets? ...

Javascript/Ajax help required

I want to create a photo gallery element which has a play button and the next/previous navigation... I can do the next and previous by using ajax load...and i do not want to preload the data for play functionality..the only way i can think of is using ajax call in a timer for play functionality...but again..calls will happen in an infini...

good tool for indenting JavaScript files

Hi All, Can you suggest any tool to re indent minified JavaScript files and compressed CSS files? ...

Break the string on Full Stop for (Chinese, Arabic, Japanese, Russian, Korean, Dutch, Hindi, Greek, Urdu) using javascript.

I am working on languge segmentation project. I applied language segmentation for English by using regular expression breaking the string at . ("Full Stop"). Now i want to provide the support for following languages (Chinese, Arabic, Japanese, Russian, Korean, Dutch, Hindi, Greek, Urdu). I want to break the above mentioned language strin...

Can this limitChars function be improved?

I've just written a limitChars() function. var limitChars = function(str, limit, endChar, preserveWord) { str = $.trim(str); var strLength = str.length; if (strLength <= limit) { return str; } if (limit == 0) { return ''; } endChar = endChar || '…'; if (preserveWord && ! str.substr(limit, 1).match(/\s/)) { ...

How to know if a timer is cleared or timed out in javascript?

Ok, really simple question. I'm taking a crash course in javascript. If I use timer = setTimeout(..., 500) to set a timer, and then clearTimeout(timer) to clear the timer, the integer value of timer doesn't change, so my question is how to know if a timer is timed out or cleared? I want to use if (timer) {...} , but obviously a positi...

Dynamical active image areas and event handling in GWT

Hi, I'm using Google web toolkit for some project mapping seismic activity of some land area. The request from users is to create a map which marked points. When user will click on some point, more detailed information is shown. So, I need to be able to draw some particular areas on a common image. Areas should be dynamically drawn (s...

passing value to JSP via javaScript

boolean canModify = UTIL.hasSecurity("PFTMODFY") && something; function name() { I need to pass a value false to something when the page loads. } window.onLoad = name How can i pass a value from JavaScript to JSP on the page load ...

combo box issue in jsp

i have combo box in jsp using Struts2: select the value of combo box, page is refreshing but after refreshing it display the default value in combo box (first value), not the selected value. how i show the selected value in combox after refreshing. here is my code on jsp. Combo box: <select name="ItemName" id="ItemName" onchange="...

Data structure visualizer for javascript

I am looking for a javascript library which renders an arbitrary (but acyclic) JSON data blob into some sort of semi-interactive HTML view. James Padolsey's Prettyprint library comes close, but its output is very verbose ("object" and "array" headers on everything, for instance), is only marginally interactive (the ability to collapse a...

Number of characters in a string

var a="password"; In any variable how to check if the length is not less than 6 characters and not > 12 $(a).len();????? ...