javascript

jquery, Showing a hidden item with a fadeIn

in jquery, how can I show a hidden div, and make it fade in? ...

How do I cache jQuery selections?

I need to cache about 100 different selections for animating. The following is sample code. Is there a syntax problem in the second sample? If this isn't the way to cache selections, it's certainly the most popular on the interwebs. So, what am I missing? note: p in the $.path.bezier(p) below is a correctly declared object passed to jQu...

jQuery: Sorting hierarchical data?

Hi everybody, I have tried for some time to work out a way of sorting nested categories with jQuery. I failed to build my own plugin to do this, so I tried to find something that were available already. Tried a few hours now with this one, http://www.jordivila.net/code/js/jquery/ui-widgetTreeList_inheritance/widgetTreeListSample.aspx an...

Graceful Degradation with JSON.Parse

If a browser doesn't support JSON.parse, would it make sense to include json.js and call parseJSON in lieu? So the code would looks something like: var z; if (JSON.parse) z = JSON.parse(yada); else z = JSON.parseJSON(yada); ...

Javascript changing source of an image

Hi Everyone! I have some javascript which runs a timer that animates something on the website. It all works perfectly but I want to get an image to change when the animation is run, It uses jquery: if(options.auto && dir=="next" && !clicked) { timeout = setTimeout(function(){ if (document.images['bullet1'].src == "img/bulletwhite....

Ajax message best practices

Say I need to use ajax to asynchronously ask the server for an xml file containing relevant data. What is the best practice on what this message should look like? Should it be a string like get_data or something similar? Should it be xml? I don't really need long polling since its a one-time (or close to it) request. Thanks. ...

Creating Slugs from Titles?

I have everything in place to create slugs from titles, but there is one issue. My RegEx replaces spaces with hyphens. But when a user types "Hi     there" (multiple spaces) the slug ends up as "Hi-----there". When really it should be "Hi-there". Should I create the regular expression so that it only replaces a space when there is a cha...

Will Long AJAX requests in SetInterval Terminate if longer than the interval

Let's say I have a line of code that looks like this: setInterval(ajaxFunction,3000); where ajaxFunction is a function that calls a PHP script and returns something. If this request happens to take longer than 3 seconds, what happens? will It terminate the current request and start over, or will it start a 2nd request and have both run...

How to call a JavaScript function in ActionScript 1?

Hello. I wold like to know how to call a JavaScript function from ActionScript 1 and get the result. Thanks. ...

adding two variables together

I have been trying for... about 4 hours now lmao. currentCalc returns 50 currentSum returns 0 when i alert them. Yet I cannot add them together with parseInt???? what am i doing wrong :'( var identRow = $('tr.identRow'); identRow.each(function () { var getIdentClass = $(this).attr('class').split(' ').slice(1); $('tr.ohp' + get...

Javascript back button for iframe parent window

I have some pages with iframes in them. I want to add a link/button inside the iframe, to make the browser go back one page in history. But I want the PARENT to go back, not the iframe itself. I originally had this, which makes the iframe page go back (if it exists): <a href="javascript:history.back()">&laquo; Go back</a> I've tried ...

innerHTML yielding undefined, but correct data is visible

var Model,node; document.getElementById('sedans').innerHTML=''; var thismodelabbr,prevmodelabbr; for(var j=0; j<xmlDoc.getElementsByTagName('data').length; j++){ node = xmlDoc.getElementsByTagName('data')[j]; thismodelabbr=node.getAttribute('model'); if(prevmodelabbr!=thismodelabbr){ ...

Bing Maps API - How can I pass extra parameters to the GeoCodeCallback

I've been banging my head against my desk with this problem. I've got the below code working properly, however what I WANT to be able to do is add my custom Title to the newShape.SetTitle(title) and my custom Desc to the newShape.SetDescription(desc) I have tried adding the "title" and the "description" to the GeoCodeCallback function ...

jQuery - change a list of elements to an associative array

Given an associative array (of the sort returned by jQuery.serializeArray()) like this: [ { 'name': 'abc', 'value': 'aaa', '__proto__': [Object] }, { 'name': 'def', 'value': 'bbb', '__proto__': [Object] }, { 'name': 'abc', 'value': 'ccc', '__proto__': [Object] } ] How can one convert this, using either jQuery or just javascript, to an...

Jquery - Loop through Checkboxes and Multiple elements

All, I have a set of elements like this in a form: <input type="checkbox" name="chk[140]"> <input type="hidden" value="3" name="ctcount[140]"> <input type="hidden" value="Apples" name="catname[140]"> <input type="checkbox" name="chk[142]"> <input type="hidden" value="20" name="ctcount[142]"> <input type="hidden" value="Bananas" name="...

check all values match using prototype

Using prototype, is there a simple method of checking that a group of values match, for example - can this code be refined to a single line or something otherwise more elegant? var val = null; var fail = false; $('form').select('.class').each(function(e){ if(!val){ val = $F(e); }else{ if(val != $F(e)) fail = tru...

Execute Javascript code in Drupal descriptions

Is it possible to execute Javscript code in the Body/Description of a Drupal node? It won't be in PHP input mode. ...

How do I return a variable from Google Maps JavaScript geocoder callback?

I am working with the google maps API and whenever I return the variable to the initialize function from the codeLatLng function it claims undefined. If I print the variable from the codeLatLng it shows up fine. var geocoder; function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(...

Javascript templating without RJS, with JSON

One of the most convenient things about RJS is its ability to render a partial so you have all your view code in one place: # task/index.html.erb <ul id="task_list"> <%= render :partial => 'task', :collection => @tasks %> </ul> # task/_task.html.erb <li> <% if task.is_completed %> <%= task.name %> - <%= task.completed_date %> ...

parsing non-strict json, one in which keys are not enclosed in quotes, with Java

I am trying to parse a string which in JSON format only that keys are not enclosed in quotes. I can very well parse this string in Javascript, but can not find a Java API which will help me parse this. All the APIs I tried assumes strict JSON format. Can anyone suggest a library which has an option to parse this, or a whole new appr...