javascript

getting values of multiple selectboxes via jquery

I want to fill an array in javascript that takes all the values out of different selectboxes with the same name so for example if i have a html like this: <select name="selectbox[]"> <option value="value1">text1</option> <option value="value2">text2</option> </select> <select name="selectbox[]"> <option value="value1">text1</option> <...

How might you unobtrusively enhance the jQuery Datepicker class?

You can pass special strings into jQuery's Datepicker class setDate() method like "+7" which will be translated into "7 days from today": http://docs.jquery.com/UI/Datepicker#method-setDate But you can't get that "+7" back out. When you call getDate() you get the calculated resulting date. I have a use case where I need to pull out...

JSLint -Tolerate inefficient subscripting?

I'm reading the JSlint Options Documentation to understand each of the available options, and have come across one that I don't quite understand, and can't find any useful information regarding it elsewhere. sub - Tolerate inefficient subscripting true if subscript notation may be used for expressions better expressed in dot n...

xhtml validation javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> onmouseover="text.show('<br /><b>XXXXXX</b><br />')" Validation Output: Error: char...

How do you print from a popup window in javascript?

I have a .Net application that dynamically creates a small HTML page and pops it up in a new window using the javascript document.open method. Everything with that functionality is working fine. Now I want to add a button to the HTML page that prints the page. I have tried using the following code to no avail: <a href='print.html' ...

asp.net textbox adding BehaviorID

can I add BehaviorID attribute for asp.net textbox and use it to be recognize by java script?? On other word, I want to to apply some java script function on asp.net text box and I want to let the java script find the asp.net text box by the BehaviorID. ...

How to create such (see image below) effect using pure HTML JS and CSS?

How to create such (see image below) effect using pure HTML JS and CSS? For a site backgrownd (And I hoe that because of JS CSS and HTML it'll be able to change colors) ...

how to load json in separate method

I need to generate the playlist dynamically. What is the best way to extract the playlist so that the playlist json below is separated into a different method or variable. Mypage.foo <script type='text/javascript'> var videoid = '1413'; var videoUrl = 'myflv.flv'; </script>...

setInterval alternative

Hi folks, In my app I am polling the webserver for messages every second and displaying them in the frontend. I use setInterval to achieve this. However as long as the user stays on that page the client keeps polling the server with requests even if there is no data. The server does give an indication when no more messages are being gene...

Making JSON Feed Work Server to Server

I have a JSON feed (which I don't directly control, I have to ask the server admins to update it), that is returning NULL, or otherwise not working when I try to access it from another server. The actual feed works fine, but I can't get it to work like a normal API. Why can I use Flickr, WhitePages, Twitter, etc's JSON APIs, but for: ht...

Allow user to add directions on a map (google maps API)

I know you can programmaticaly add markers for directions on the map. But how do you let the user do that? Like on the Google maps site, you just right click and then click on 'directions from/to here' and the marker is added. This functionality seems to be absent from the API. EDIT: Maybe I wasn't clear enough. I am not talking about t...

Javascript/JQuery if statement

This is probably pretty simple, but I can't figure out how to do it: I have this code: $.post("/admin/contract", { 'mark_paid' : true, 'id' : id }, In pseudo code, how can I do this: $.post("/admin/contract", { 'mark_paid' : true, ...

Niceforms and jQuery events

Our design agency has supplied HTML that uses NiceForms. The problem I am having is that this mucks up jQuery event binding. I have the following code: keys = $("#key input"); $(keys).each(function(){ $(this).change(function() { console.log("hi"); }); }); If I disable NiceForms this code works but with Niceforms enabled it do...

Getter/setter on javascript array?

Is there a way to get a get/set behaviour on an array? I imagine something like this: var arr = ['one', 'two', 'three']; var _arr = new Array(); for (var i=0; i < arr.length; i++) { arr[i].__defineGetter__('value', function(index) { //Do something return _arr[index]; }); arr[i].__defineSetter__('value', function(index, val) ...

Using JQuery to replace multiple instances of HTML on one page

I've made a script which copies the alt attribute of an image and puts it into a <span>. It also formulates the information divided by a hyphen. It works like a charm, but only with one image. I would also like to wrap a <div> around the image to prevent unnecessary markup. Script snippets: HTML: <div id="hoejre"> <p> <s...

jQuery uses (new Function("return " + data))(); instead of eval(data); to parse JSON, why?

This link shows you that jQuery uses (new Function("return " + data))(); for older browsers, to parse a JSON string instead of eval(). What are the benefits of this? What if the JSON string isn't safe? ...

Html string replace a span's class doesn't work in IE?

Someone tried to recreate smarty in js: // actually from a template file, not hardcoded in the javascript html = '<span class="{test}">yay</span>'; html = change(html, 'test', 'foo bar'); function change(html, key, value){ html = html.replace('{'+key+'}',value); html = html.replace('%7B'+key+'%7D',value); return html; } ...

Strophe javascript prevent disconnection on some delay

Hello, I am developing javascript XMPP application which uses Strophe library to connect to Jabber server. I need to engage the thread for about 5-10 seconds when Strophe connects to the server. Thread is engaged by running java applet and after it releases the thread it goes back to handle XMPP events, however at the moment I cannot man...

What is the instanceof operator in JavaScript?

What is the instanceof operator in JavaScript? I saw this in a blog post by John Resig, and didn't understand what does it means in regular JavaScript code (without that library). ...

Display text returned from json post call

I have the following javascript: $.post("/Authenticated/DeletePage/" + PageId); showStatus("Page deleted...", 10000); I would like to instead pass showStatus() text that is returned by the $.post() call, rather than hardcoded text. How do I do this? ...