javascript

JavaScript lib reference variables in core script?

We have an HTML page with some global JavaScript variables. We have some utility functions that manipulate these variables. Can you move these util functions to a separate JavaScript file and include the file using the <script> tag? Wasn't sure if the functions in the external file could get/set the global variables that are defined i...

What do the underscores mean in DOM object detail view? (Firebug)

Three (out of 8 or so) of the parameters in an object have an underscore at the beginning of their name. The underscores aren't in my json object and I can't decipher why Firebug would add them in. The same properties are listed later in the object but without the underscores. I'm sure it's trivial but I'm curious to know. Here's a scre...

How to DRY up my jQuery code and make it more readable/maintanable?

I'm starting to do a lot of jQuery programming. I'm finding that my code is becoming a little hard to maintain and is not all that readable. My javascript is being included on every page of our web application, even though it is only used on one page. This has the benefits of having the javascript cached before loading the page, but I'm ...

How can I translate my jquery to javascript?

I have $('#hidden-data').find('#' + $(this).attr('id')).html(currdata); var hiddata = $('#hidden-data').find('#' + $(this).attr('id')).html(); I want to translate this to javascript but my brain is melted. Please help ;p ...

Script counting characters in a text box using Javascript not working?

I need to enforce character count limit in my application. I found some JavaScripts from web but they are not working, Here is my code. I would be very thankful if someone can kindly see the code & correct whats causing problem. <HTML> <HEAD> <script type="text/javascript" src="http://ajax.googleapis.com/ ajax/libs/jquery/1.4.2/jquery....

Calculating sliding averages

I'm not even sure what sliding average is, but someone told me it would help with something I'm working on. I have a table of random values -- table[n] = random(100) / 100 I need to populate table2 with their sliding averages. I think this is the terminology. Let me know if it doesn't make sense. ...

IE javascript problem with break or classname

Hi, i'm not really sure whats the problem here, it works with chrome and ff but not ie. var newdiv = document.createElement("div"); newdiv.innerHTML = xhr.responseText; el = newdiv.firstChild.nextSibling; var next; do{ next = addpoint.nextSibling; if(next.className != "commentstyle golduser") break; }while(addpoint = next); document.get...

remove attribute of html tag

Is it possible to remove the attribute of the first html tag? So, this: <div style="display: none; ">aaa</div> becomes <div>aaa</div> from the following: <div style="display: none; ">aaa</div> <a href="#" style="display: none; ">(bbb)</a> <span style="display: none; ">ccc</span>​ Many thanks in advance. ...

Use Javascript Alert To Keep Users On A Page

I am creating an internal web based application that will not be the target audience of the web. I understand the frustration of alert boxes and forcing people to do certain things. With that said, what I am attempting to do is create a javascript function, that unless a user clicks a link on a specific page, if they try to navigate aw...

How to auto submit using PHP

I have oscommerce based website. The product's attributes are read from text file. All i want is to press the "insert product" button automatically either through AJAX or anything else. So that i can add 100 product daily in automatic way instead of manually uploading them using text file and press "insert product" button 100 times. Ple...

linking two objects // updating value on first and second

function associate( obj1 ,obj2 , key ){ if(typeof key === 'object'){ for ( var i in key ) associate(obj1, obj2 , key[i]); } else { obj1.watch(key, function (id, oldval, newval) { obj2[id] = newval; return newval; }); } } I wrote this function because if h...

Doesn't External JavaScript files lead to more clientside processing?

Hi all, I was thinking about external HTML files, and it occured to me, that if I group the functions from several HTML pages, in one JavaScript this will lead to extra clientside processing. Basically, I would like some idea of whether this is correct. Here is my thinking. Suppose I have one JavaScript file for five pages. If the u...

getJSON and invalid label

I am trying to get json data from a url. Url is working ok in FF. I am trying code like this $.getJSON("http://testsite.com/1234/?callback=?", function(data){ //here i am getting invalid label error** } ); When i am trying without callback=? i am getting empty data $.getJSON("http://testsite.com/1234/", function(data){...

Reading rails text_field names with javascript

Here is what I'm trying to do <% form_for @color, :html => {:multipart => true, :name => "color_form"} do |f| %> <%= f.text_field :head_color %> and I want to use this javascript document.color_form.color[head_color].value; javascript obviously doesn't like this and throws an error. The problem is that I can't use text_field_tag. ...

Editor for firebug or 'how to embed a custom editor' in a firefox tab?

Firebug is great for javascript development, but doesn't allow to edit the code (the 'edit html' in the firebug is not usable, doesn't save the file and even if it did, it is just an plain text editor without any coloring). I usually have my editor opened next to Firefox, but the constant switching feels aarrgh! To have the editor insid...

Javascript: prototypal inherence and super constructor

hi, how can i call super constructor from the inheriting object? for example, i have a simple animal 'class': function Animal(legs) { this.legs = legs; } i want to create a 'Chimera' class that inherits from Animal but sets the number of legs to a random number (providing the maximum number of legs in the constructor. so far i have ...

Response Object not returning Excel stream in update Panel?

I am generating an Excel file upon a click of a button in an update panel. It is throwing a parsing error. Please see below code. If I keep the button outside the update panel it is working fine. Why isn't it working in the update Panel? Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("Content-Disposition", ...

Client side includes vs server side includes?

We have an HTML page with multiple div blocks. We want to separate these div's into multiple files and then combine them all together into a single file - is it best to use server side includes (JSP in our case) or client side includes? Note that we're using JQuery - not sure if JQuery has a clever way to do the includes. ...

adding day to a javascript date object does not work when moving to the next month

Hello All, I'm having an issue when working with javascript date objects, specifically, when trying to add a day to a date object. The function I'm writing takes a start date and creates a list of the next seven days, used as the headers of a "week view" calendar app. When the week dates it's determining are within the same month, my f...

IE6/7/8 Out of Memory?

I was doing some cross browser testing on certain piece of functionality today, and ran across a rather nifty little gem. In IE8: Out of memory at line: 99 In IE7: Out of memory at line: 100 In IE6: Stack overflow at line: 101 From what I've been able to dig up, most of the time these messages start appearing, it's an issue with havi...