javascript

Getting Id of a .net dropdownlist in javascript on client click

I need to get the ID of a dropdownlist (ASP.Net Control) So that I can tell if an item has been selected. Right now I am trying to just write the count of the dropdownlist to an alert box as follows: OnClientClick="alert(document.getElementID('<%=ListBox1.ClientID %>').options.length) The error I get is 'document required.' ...

how to load an english-site image, if the spanish-site-image does not exist

I have a multiple language site. With html, javascript, may be ajax if an image does not exist in spanish folder, it should load image from the english folder. path example english site : images/home.jpg spanish site : es/images/home.jpg Today i have message.properties ... stuff for doing text conversion message.properties message_es....

How to execute a JavaScript in a URL

I need to execute a certain JavaScript when accesing the custom URL. At this time the code behind the button that triggers the JavaScript that I need to be ran is this: <a class="button" href="#" onclick="new Request.HTML({ method: 'post', url: '/ro/somefolder/anotherfolder', data: {'user_id': 777, 'score': 1, 'redire...

How to scroll to show a part of a webpage

What are the different ways you can control/read the Scrollbar in a web browser with JavaScript, apart from anchors? -- Unless you can dynamically create anchors and tell the browser to scroll down to that. ...

Auto-selection of <option> based on input field, with some caveats

I have a SELECT element in which I need to auto-select the appropriate option based on the first half of a postcode entered in a text field. British postcodes are of the form AB12 3CD, where the first section consists of 1-2 letters representing the county and a number representing the area within the county. The last 3 characters are ir...

Slider Bar/Pins algorithm

I have a slider with x number of bars that each represent a range of values. Each bar has an upper and lower handle that is used to manipulate the range. The bars can be interconnected, thus, some of the handles will affect two bars(i.e. the handle is in the middle of the two bars), of which, their movements can affect movements of ot...

How can I check if an element is within another one in jQuery?

Is there any direct way in JavaScript or jQuery to check if an element is within another one. I'm not referring to the $(this).parent as the element I wish to find can be a random number steps lower in the tree of elements. As an example, I would like to check if < div id="THIS DIV"> would be within < div id="THIS PARENT">: <div id="T...

FireFox capture autocomplete input change event

I'm trying to subscribe to change events on an input tag for an ajax auto complete form. These change events are not firing when the user clicks an autocomplete suggestion from FireFox. I've seen fixes for IE, but not FireFox. You can view this behavior here Steps to recreate: type any input in one of the boxes and click submit. Sta...

[JavaScript] Unit of Measure Conversion Library

What is the best/most elegant way to abstract out the conversion of units of measures in the client, based on a user-preferred unit of measure setting? For example, let's say user A's preferred unit of measure is "metric", while user's B's preference is "imperial". Now lets say I've calculated the area of something in meters squared. W...

onkeydown event for html form not firing in IE 7 or FF 3

I am writing an asp.net application and have a form where a user must press a key to have a textbox become visible so that he/she can login. When the key is pressed, I want a label to disappear and a textbox to become visible. For some reason the 'onkeydown' event is not firing in FF or IE, but it works fine in Chrome. The application wi...

Choosing the right design for a website?

I'm a programmer (hobbyist, but looking to make it a career) by nature so when I was asked to design a website I felt a little out of place (most of my applications don't have pretty UI's, they just work because I'm the only one using them). I have been looking into how I could design my website and started wondering how you guys decide....

webrick server / ie6 truncating javascript files in development mode

I'm using webrick to run my rails app in development mode. The page includes 4-5 javascript files, which are also being served by the same webrick instance. When I load the page on ie6, it appears the javascript files are getting truncated after the first few lines -- can anyone explain that? e.g. if the page contains this script tag:...

Multiple Frames, JavaScript, and Navigation History

Hi folks, I inherited an eCom site which operates by multiple frames. There is a sidebar frame that may have a list of products in a category or be a blank page. And there is a main content frame that will hold category items, or content, or the shopping cart. It is a nightmare of spaghetti code includes and I don't have access to th...

Get entire content of page?

So is it possible to snag the entire content of a page in its current state. For example, if interacting with a page, via jquery, I've modified the document by either inserting content, or by adding or removing class names. Is it possible to get the markup of this document in its current form from starting html tag to html tag? ...

Report decent printing in the web.

As a web systems programmer, I'd like to generate some reports and be able to send it to the printer directly from my user's browser, wich is in the client side, not needing to generate PDFs or something like this. I would like to be able to: Print user friendly paging, something like "Page 1 of 3" Print some things in the bottom of e...

How to protect a site from API outages?

Watching the effects of today's Google outage across the web got me thinking about how to prevent this in the future. This may be a stupid question, but is there a good way to include external APIs (e.g., Google's AJAX libraries) so that if the API is unavailable, the including page can still soldier on without it? Is it generally a bad ...

Creating the checkbox dynamically using javascript?

I am trying to create a checkbox dynamically using following html/javascript. Any ideas why it doesnt work? <html> <head> </head> <body> <div id="cb"></div> <script type="text/javascript"> var cbh = document.getElementById('cb'); var val = '1'; var cap = 'Jan'; var cb = document.createElement('input'); cb.type = 'ch...

Regex to match www.example.com only if http:// not present

I have the following regex that isn't working. I want to match the string 'www.example.com' but not the string 'http://www.example.com' (or 'anythingwww.example.com' for that matter): /\bwww\.\w.\w/ig This is used in JavaScript like this: text = text.replace(/\bwww\.\w.\w/ig, 'http://$&amp;'); I know the second part of the regex do...

Why does gzipped html file display without JS and CSS?

I have an html file saved in gzip format. The browser displays the html file but without the javascript and CSS. Non-zipped html files in the same directory do display correctly. In addition, I saved the source from the compressed html file and it reopened correctly, with JS and CSS applied. What is different about displaying the zipp...

How does this JavaScript function create a GUID?

I came across this JavaScript function and I don't understand quite what it's doing, especially with the use of 0xF. What does the 0xF do, exactly. It looks like a null nibble to me. function() { var g = ""; for(var i = 0; i < 32; i++) g += Math.floor(Math.random() * 0xF).toString(0xF) return g; } ...