javascript

retrieving text using this.text() and jquery

I'm trying to get the text within the clicked linked by using this $(".ajax-append").click(function(event) { $.get("includes/fight.php?name=test", function(html) { console.log($(this).text()); console.log($(this)); // append the "ajax'd" data to the table body $("table tbody").append(html); ...

jQuery slideToggle() callback function

Here is the jQuery slideToggle function: $('.class').click(function() { $(this).parent().next().slideToggle('slow', function() { // how can I access $('.class') that was clicked on // $(this) returns the $(this).parent().next() which is the element // that is currently being toggled/slided }); }); In th...

Improve code for drop down menu (HTML/CSS/JavaScript)

Hello! Based on this tutorial, I've built a drop down menu for template from Styleshout.com. medigerati helped me so that it works now - at least in Firefox 3.5 and Internet Explorer 8. You can see the menu in action here. But unfortunately, it doesn't work well in all browsers. In Internet Explorer 6 - for example - it isn't displaye...

Generating a class from an object (JavaScript)

I'm trying to generate a class from an object in JavaScript. For example: var Test = { constructor: function() { document.writeln('test 1'); }, method: function() { document.writeln('test 2'); } }; var TestImpl = function() { }; TestImpl.prototype.constructor = Test.constructor; TestImpl.prototype.method = Test.method; var x =...

jQuery Standards and Best Practice

I’m currently responsible for rolling out the use of jQuery to the community of Web Developers within our company. Part of this involves presenting a course, however another part involves communicating standards and best practice. If you Google 'jQuery best practice', you’ll probably find the following among the search results. http://w...

Want a javascript function to run every minute, but max 3 times.

Hi, I have a ajax javascript method that pulls data from a page etc. I want this process to run on a timed interval, say every minute. But I don't want it to loop forever, so max out at 3 times. What is the best way to implement this? ...

Problem with hide/show select box in IE7/8

Hi. Ive been trying to use an untested function that Justin Johnson coded(thanks again mate), but ive been struggling with IE errors. Im a begginner in javascript. Basically what happens is this: User chooses an option from a select box. Other corresponding select box becomes visible. If there is any other select box that was choosed ...

save dynamically created form fields between page requests

I have a form in which the user can dynamically add/remove name/value pairs of fields eg: inventory list: [description text input field] [quantity text input field] [remove item button] [add item button] so basically the user can add more inventory items: inventory list: [description text input field] [quantity text input field] ...

How can I make my .htaccess file allow Safari & other browsers to open GZIP?

I'm using an .htaccess file to allow my pages to call gzipped JavaScript files. It works fine in ie8 & ff3, but the script is not loaded in Safari (or Chrome). Here is the .htaccess file I'm using: <files *.js.gz> ForceType text/javascript Header set Content-Encoding: gzip </files> Then, for example, I can call JS files from my HTML...

How Facebook detects that you are away?

How Facebook detects your away state (you know, the half moon in the chat window)? How you can check in Javascript if a person is away from your page, even if it's open in the browser? Do you think there is any library that already does it? ...

How to insert javascript in asp.net master pages

Hi, We're having some trouble with including javascript in masterpages. The "~/" root shortcut doesn't seem to work, and so we're having to manually enter in the path to the javascript from where it will be used, for example: "../../tooltip.js" However, the problem is that if the nested page is in a different path, this approach does n...

Slider in dashcode web app?

I am trying to make a web app in Dashcode that uses a range slider. I see that the code library has code for "get range slider value" and "set range slider value," but there is no range slider part. So how do I make a range slider? I'm very new to Javascript. ...

How do I position an element 40 pixels beneath the lowest reaching DIV on a page when a scrollbar is present?

I am branding several sites I recently created with an image that reacts to hovering and links back to my own site. I'm dynamically inserting the markup and CSS with a jQuery append function that absolutely positions my logo in the bottom righthand corner of the client's site, and it's working great for the most part. However, I need to ...

Help with parsing Bit.ly JSON response in Javascript (url in json response)

I'm trying to extract the shortUrl from the Bit.ly JSON response. The problem is the original url is included in the response, using the dot notation to traverse the response doesn't work? I can get the other attributes (errorCode, errorMessage etc), but I can't get anything under results beacuse of the url. Am I missing something? Th...

JQGrid / Date Picked within Add/Edit window

I have been able to work the Date Picker into JQGrid when editing inline, but I am unable to use it inside the add/edit window. Does anyone have instructions on how to do this or an example I can look at? demo from that site of what I am trying to do: http://www.the-di-lab.com/demo/apples I read that I could use the following method bu...

How to save user's choice of theme of web pages

I have a simple web app, it's done with several JSP pages. I would like to add some style to it. I would like to provide some color theme options say like in a drop down box. I have little basic knowledge of CSS. Here are my questions: I think I should have all styles in one CSS file, and use format like selector#different_ids {propert...

Google Maps API - GDirections.getDuration() returns null first time, works second time

I'm having a dilemma with the Google Maps API - I'm using the GDirections object to get the time needed to travel between two points. I've tested the following code in Firebug, so that the chances of the rest of my code affecting this one call is low (I can't link to the actual map; it's on a local computer). var start = "NY, USA"; var...

use of javascript array new Array(n) declaration

Basic javascript question - Since there is no hard limit for arrays as the case with Java (i.e. indexoutofbounds exception), what is the use of the declaration where we specify the length property? var a = new Array(10); I know it predefines the length and puts "undefined" into those empty spots - is that reason enough for having it?...

Strange behavior from setInterval()

I'm trying to do a very basic date-difference calculation with javascript, but am getting mixed behavior from setInterval(). This updates constantly: var init = setInterval(function(){ document.getElementById("txt").innerHTML = new Date(); }, 1000); But this only updates once: var init = setInterval(function(){ var today = new D...

Custom javascript class and private variable scope issue

I am having some trouble with the classic javascript local variable scope topic, but dealing with a JSON variable. I have looked at other questions here regarding the same thing, but nothing has matched my case exactly, so here goes. I have a class that I have made from javascript that has 3 methods: func1, func2, and func3. I also ha...