javascript

Dynamically adding a table row with jquery, then add auto populate select box in each new row

Hey, guys, I tried to ask this yesterday but I didn't explain myself clearly or simply enough. I have a form that is setup in a table. User can add new rows (and more form elements) as they please. Each row of this form needs to have its own separate select box and corresponding subcategory select box. So basically... Name | Select...

Sidebar missing after adding a custom decorator to a form element

the side bar is in the layout.phtml file. i am very confused why does adding 1 decorator to my form, cause my sidebar ... hmm actually its every thing after that section#main - i am using HTML5 - to go missing layout.phtml ... /* scripts and all */ ... <body> <header> ... </header> <nav> ... </nav> <div class="clear" /> ...

Pass $this to function

How can I pass the $this (the self keyword) to a function in Jquery $(document).ready(function() { $('.nav a').click(function() { var direction = $(this).attr("name"); submit_form($(this)) }); function submit_form(this) { // do some stuff with 'this' ...

JavaScript slowness outside events

How do I diagnose web page performance problems if none of my JavaScript events seem to be the cause? I have a web application using jqGrid. Clicking on the grid causes a 2-3 second freeze before anything happens (including any click events being hit). Clicking anywhere else on the page is fine (instant response). Removing rows red...

Returning values from nested functions in Javascript

Consider this code (shortened) function getSecret() { db.transaction( function (transaction) { transaction.executeSql( 'SELECT * FROM table LIMIT 1;', null, function(transaction, result) { var row = result.rows.item(0); var ...

auto fill fields and submit from another server, is it posible?

let's assume there is a site http:/ /testsite.com, with some filds and submit button. Is there a way, to write a javascript script, which will fill all filds with values i want, and make submit operation automaticaly? Is it possible, maybe there is some documentation about it? Thanks UPDATE i don't have access to the script of site,...

How can I transform a custom overlay in Google Maps to account for projection?

I'm developing an application that uses Google Maps API v3. I want to make custom overlays that are squares exactly 1000km on each side (each overlay is actually a 1000x1000 transparent png, with each pixel representing 1 square km). My current implementation is this: function PngOverlay(map,loc) { this._png = null; this._loca...

Using XHR to send large amounts of data via POST.

Hello, I have an XHR that uploads large amounts of data to the server. This XHR dies intermittently and seemingly without pattern. Currently my code looks like this: function makeFormData(data) { var formdata = ""; for (var key in data) { formdata = formdata + "&" + key + "=" + encodeURIComponent(data[key]); } re...

Sys.Application.add_load in .NET 2 vs .NET 4

I converted a .NET 2.0 application in VS 2005 to a .NET 4.0 application in VS 2010 and am experiencing an issue registering a script to run after the page has been fully loaded. I am using the following vb.net code to register a javascript function. This vb.net code is called in the OnPreRender of a custom server control that only gets...

On-Click img border = #color - Multiple images - Only need 1 highlighted at a time

Basically what I am trying to accomplish is create a list of images (let's say 10) and upon clicking any of these images, their border changes to a specific color; currently accomplishing this with a simple onClick event with JS. That's not an issue. The trouble comes in when clicking a second or third or forth image; all of the images c...

Explicitly setting load order

I have a slight problem. I need to show some safety information in a JS drawer that the page loads with open. The images creating the drawer are kind of hefty and as such the safety text in the drawer render prior to the background, creating a really ugly loading experiance. Is there a easy way I can say DO NOT LOAD safetyText UNTIL s...

Extract values from a 'binary format' file and create text file with fixed field sizes

I've used JavaScript to get the data through the internet (I'm interfacing with a brokerage firm's API functions), but unlike most of the rest of their API's, this one returns the data in a 'binary' like format. Here is the layout of the file I get back: Field -------- Type ------------ Length(8 bit bytes) --------------- ...

Need the Javascript equivalent of this C# code to add values to a cookie

I need some help creating the necessary Javascript to add values to an existing cookie. I know how to do it in c#, but it needs to be done in Javascript in this scenario. This is the C# Code: HttpCookie myCookie = HttpContext.Current.Request.Cookies["SiteSettings"]; myCookie.Values.Add(varName, varValue); myCookie.Expires = DateTime.No...

Is there a & logical operator in Javascript

I was wondering if there is a "&" logical operator in Javascript. I tried running 1 & 0 and 1 && 0 in Firebug(Firefox) and it returned a 0 for both. Someone told me that C# accepts both & and double &&, double being more efficient as it will exit the comparison loop as soon as a false is encountered, but I was not able to find any inf...

Why do IE/Chrome initially give incorrect clientHeight and scrollHeight for a textarea?

Chrome (and IE when browsing local files) gives an initial value for the clientHeight of a textarea element that is incorrect. How do I get IE and Chrome to give the correct values? (Problem demo'ed here) I am setting the position and size of the textarea via CSS fixed/absolute positioning. Then I am checking the value of clientHeight v...

Move focus to a particular field

I have a button that will add show a form on the page. how can I move the focus to the first field of the form when that button is clicked? simple example: HTML: <form style="display:none;" id="newForm"> <input type="text" id="firstField"> </form> <input type="button" id="showForm" value="add new"> jQuery: $("#showForm").click(...

Getting a reference to a nested frame object doesn't work everytime in IE8. It works when adding an alert()!!

I have an odd problem with IE8. I am trying to get a reference to a frame (same domain) object. The frame resides inside an iframe. The iframe resides deep inside multi level div's. The whole html is an output from an ASP.NET server control. jQuery code to get the reference is jQuery(top.window.frames['the_iFrame'][1].document).content...

How do I select the first H1 element in a TD?

I am (stuck) using Prototype 1.3.1 and I'm having a hard time moving from jQuery to the older version of this library. Unfortunately, the extensions I'm writing are for a vendor-provided system to which we can not update. So, no moving to a newer version. I'm having trouble finding out how to do things without the modern CSS selectors...

Returning variables inside JS / JSON functions

Hello, I'm trying to understand JSON, callbacks, etc within JS. From the altered example below, you'll see that I'm in a function callback from $.getJSON. Then, I jump into getSomething() and expect it to alter my result variable. It alters it within the scope of the function, but not when I jump out of that function. You'll see f...

JQuery Ajax call, return value problem

This is broken, reposting as an answer ...