javascript

My jQuery code is working, but is it very crappy from a programmer's point of view?

I cobbled together this jQuery function. It's purpose is to calculate the margins of all img elements inside div.article in order to balance the image's height with the baseline grid of the document, wich is 20 px. In order to match my baseline grid, every image height should be a multiple of 20. If that's not the case, e.g. one image's ...

How to calculate the number of characters(spaces are excluded) within a pair of tags in JQuery or Javascript?

How to calculate the characters(spaces are excluded) within a pair of tags in JQuery or Javascript? What function? For example: <pre id="mytext">This is the text. This is the text.</pre> How to know how many characters or words in $("#mytext")? ...

Why does select with onfocus not work in IE?

I want to highlight a select element with a background color to indicate, it is mandatory. When the user opens the menu by clicking on it, I want to remove the background color, so it looks nicer and is more readable. This works just fine in Firefox, Chrome and even IE6, but on IE7 & 8 the pulldown doesn't open on the first click (or is ...

Turning a DIV into a click-and-drag viewport

Does somebody know an unobtrusive, Prototype or no framework based way to turn a DIV with big content (e.g. a map) into a clickable and draggable "map" container with fixed dimensions, very much like Google Maps? I want to display HTML chunks in a large input form. Those chunks can exceed the space available (Each chunk can have a viewp...

resized image coordinates in html

Hi, I have an image in a html page resized to 400px width with css .cropbox { width: 400px; height : auto; } Also i have a js on that image that let the user select one point of the image. Of course the coordinates are relative on the resized image. How can i get the coordinates relative on the original image? Something like newx = o...

Dropdownlist inside a Gridview

HI, i am working on dropdownlist inside datagrid if i select one value in any row of dropdowlist then if i am select same value in another row of a dropdown then display message 'already added'. How to do this using javascript Ravi. ...

Javascript update to HTML table cell (from thousands to millions)

I need to create some javascript on my web report which converts table values to thousands or millions (eg divides or multiplies by 1000). The trouble is that each value is 'clickable' (ie it is wrapped in an anchor tag). Is this possible? <table class="Table" > <thead><tr> <th class="l Header" scope="col">£000s</th> <th class="l ...

iPhone Safari Web App: Seeking overview of iPhone-specific features

I am trying to get an overview of what kind of native iPhone features I can get access to when I write a Web App (using html/css/javascript, running in Safari). Meaning: I like to know whether I can get access to features specific to "smartphones" in general and iPhone/iTouch in particular (accelerometer, address book, photo library, th...

Javascript disable/enable event and $addhandler

I am fairly new to JScript and I am looking for a way to subscribe to the event when a textbox is disabled or enabled. I am creating a AJAX Extender Control and I am subscribing through the JScript: $addhandler(textbox, 'EventName', Function); I have it working for "click", "focus" and "blur", but I'd like to get enable disable worki...

Dojo: Edit Whole Row in Datagrid

I know one can edit a single cell in a dojo datagrid but I would like to be able to press a button on the datagrid row, and have the entire row be put into an editing state. Is that possible to do with dojo? ...

Dropdown list inside a datagird

Hi I am working in dropdown list that is inside a datagird i am binding data to the dropdown list using dataset. My question is if i select a particular value in a dropdown list from next row onwards if i select the same value in the another rows of dropdown list then it will display a message how to achieve this by using java script ...

How to get the HTML for a DOM element in javascript

Hi, Imagine I have the following HTML: <div><span><b>This is in bold</b></span></div> I want to get the HTML for the div, including the div itself. Element.innerHTML only returns: <span>...</span> Any ideas? Thanks ...

Reassigning the click event from click (using jQuery)

Hi everyone! I'm having some trouble with this javascript (using jQuery): $(a).click(function(){ alert('hi') this.unbind.click(function(){ doSomethingElse(this); }) }) When a is clicked, it is supposed to reassign its own click event. Unfortunately, it fires the second click event as well. I know this is to do with p...

ASP.NET GridView row count using Javascript

Having the GridView client control ID, I would like to get some ideas on how to count the GridView rows or at least be able to tell if there is at least one row on the Gridview the restriction is that I can only use client side code (JavaScript in this case) ...

I add 10 functions to a code, I don't even call any of them, but the code stops working!

Alone, this code works: CustomButton = { 1: function () { alert("Just testing") }, } I add the code below and the code above stops working: function getvisitingnow() { return document.location; } function getcontents(uri) { var req = new XMLHttpRequest(); req.open('GET', uri, true); req.onreadystatechange = function (aEvt)...

Nested JSON in IE6 causes problems.

I'm making a request to a JSON page using jQuery's $.getJSON method, and from the returned JSON i'm creating some HTML and putting it on to the page. The problems appears when I have a nested JSON object, i'll show you an example later. First off, if I make a request to my JSON page and return the following JSON, the function works ju...

Asp.Net script in external js file

How can I use server-side script in an external js file to grab a reference to a dom element? The following works as intended when used as inline-script, but is returning null when I move this to an external js file. $("#<%= gridResults.ClientID %>"); ...

Deleting any element, the reassigning the count value

Sorry about the cryptic title, it's hard to describe! I am using the following script to add a row to my form when a button is clicked: $(document).ready(function() { $('#btnAdd').click(function() { var num = $('.clonedInput').length; var newNum = new Number(num + 1); var newElem = $('#input' + num).clone()...

Get object within JSON object only by knowing its position, and not name

Hi, I'm currently looking into the Twitter-API - specifically the daily trends-API (http://search.twitter.com/trends/current.json). Example return from Twitter { trends: { 2009-11-19 14:29:16: [ { name: "#nottosayonfirstdate", query: "#nottosayonfirstdate"...

Ajax not supported?

I have a page that uses an AJAX request (using Prototype's Ajax.Request()) to validate something. We keep very detailed logs of all of the requests. Occasionally customers will complain that they are entering something and it is not being validated. In such a case I check the logs searching for their IP address, time of their email, a...