javascript

Trouble parsing multi-level JSON

I have a chunk of JSON which looks something like: { "map": [ [ "zimbraFeatureCalendarUpsellEnabled", "FALSE" ], [ "zimbraPrefCalendarDayHourStart", "8" ], [ "zimbraFeatureOptionsEnabled", "TRUE" ], [ "zimbraAttachmentsViewInHtmlOnly", "FALSE"...

href's javascript single and double quote problem

I am having problem with escaping the single and double quotes inside the hrefs javascript function - I have this javascript code inside href - its like - <a href = "javascript:myFunc("fileDir/fileName.doc" , true)"> click this </a> Now, since double quotes inside double quote is not valid - I need to escape the inner double quote...

How to append child before. prototype

I making a website with the javascript library. If the user select a option on a dropdown (select) box there must be added a label and a textbox. This I do with the appendChild option. The only problem with the appenChild option is that the items always be added after the items in used element. This is my code: var newFreeformLabel = do...

Comment Box Widget

Hi, I need to embed a comment box on pages for this site i'm working on. Basically, a box where you can leave your comment, and that displays other's comments. Backend should include basic moderation options. We have little control over the code of the page, and therefore we're looking into 3rd party widget. Ideally, something that is s...

Dynamic javacript slideshow...

I have a javascript slideshow that pre-loads images out of a mySQL database and then displays them one at a time in an image tag in the HTML document. Briefly, it accomplishes this by pre-loading images like many slideshow tutorials show on the web, but instead of using static images (i.e. images/image1.jpg etc.) it uses a dynamic image ...

How do I change the selected item in a dropdown based on user input in a text box?

I have a select dropdown that could possibly contain over 1000 items for a large customer. <select name="location" id="location"> <option value="1">Store# 1257</option> <option value="2">Store# 1258</option> ... <option value="973">Store# 8200</option> <option value="974">Store# 8250</option> <option value="975...

How to create jQuery Tabs out of Markdown

Hi, I'm currently running a PHP based Content-Management-System that generates its HTML content with the help of Markdown Extra. Most of the content is structured by headings and sub-headings which results in a very long page. At the beginning of each page I create a table of contents with the help of a list and Markdown Extra's Header ...

please share the code for Calendar or Date picker (Popup) in JavaScript to implement in JSF

please share the code for Calendar or Date picker (Popup) in JavaScript to implement in JSF ...

onchange="javascript: document.my_form.submit()" vs. normal submit

I have a select field within a form: <form id="myform"> <select id="value" onchange="javascript: document.myform.submit()"> <option>.... </select> </form> After the form is submitted, it is impossible to use the 'back' button without resubmitting the form. However, if I use a regular 'submit' button, it is possible. Is there a w...

Getting Firefox 3 to work with JSUnit

Thus far this is what I've tried, I'm using Firefox 3.07 Make sure in about:config that the property browser.cache.check_doc_frequency is set to 1 which the browser interprets as "check for a new page every time". Make sure in about:config that the property security.fileuri.strict_origin_policy is set to false. When opening your browse...

Autocomplete with different values than the title

Hey everyone, I'm trying to make an autocomplete form using jquery, but I've run into an issue. I'm trying to make it so that when a user starts typing in the name of a place that's in our database, it shows them the full name of the place in the autocomplete, but when they click on it, the textbox gets filled with the address of the pl...

Detect difference between & and %26 in location.hash

Analyzing the location.hash with this simple javascript code: <script type="text/javascript">alert(location.hash);</script> I have a difficult time separating out GET variables that contain a & (encoded as %26) and a & used to separate variables. Example one: #code=php&age=15d Example two: #code=php%20%26%20code&age=15d As you...

decodeURIComponent vs unescape, what is wrong with unescape ?

In answering another question I became aware that my Javascript/DOM knowledge had become a bit out of date in that I am still using escape/unescape to encode the contents of URL components whereas it appears I should now be using encodeURIComponent/decodeURIComponent instead. What I want to know is what is wrong with escape/unescape ? T...

Javascript image slider

Hi I'm looking for a simple Javascript Image slider that have the following features. A little horizontal box that shows images thumbnail and slides them. Once you select a thumbnail, the image shows on a div or some else where on the page. I want something easy and pro looking. Thanks ...

Javascript: How to make a Control send itself in a method.

<a href="" id="someId" onclick="SomeMethod(self);"></a> Where SomeMethod could have: function SomeMethod(item) { item.setAttribute('name', item.id); } Instead of: function SomeMethod(itemId) { var someItem; someItem = document.getElementById(itemId); someItem .setAttribute('name', someItem .id); } Silly example, but the...

Is there a way to use window.hasOwnProperty() in Internet Explorer?

I have a method, that perfectly works in Firefox, with which I can determine the name of an instance of a particular javascript object (please don't ask why I need it...). Fr example: var temp = new String("hello!"); var theName = getVarName(temp); //returns "temp" This method uses "window.hasOwnProperty()" which doen't work in Inter...

Table/Grid Layout - hardcoded HTML vs generated by Javascript

Which is the more efficient way to create the following, hardcoded HTML or Javascript manipulation: A pre-defined grid, i.e. constant number of rows and columns, with boarders and styles and event handlers. Is it better to have many divs written in HTML. <div class='tl' id='c00' style='top:0px; left:0px;'>A</div> <div class='tl' id='c0...

Wiring code in JavaScript

I'm currently facing a conundrum: What is the right way to wire together 2 javascript objects? Imagine an application like a text editor with several different files. I have some HTML page that represents the view for the notebook. I have a file notebook.js that contains class definitions for NotebookController and Notebook View. No...

Cut-and-dry AJAX functionality for a library I'm writing for myself; will this suffice?

First, the code in question: ajax = function(url, cb) { xhr = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { cb(xhr.responseText); }; } xhr.open('get', u...

How do I fix incorrect inline Javascript indentation in Vim?

I can't seem to get inline Javascript indenting properly in Vim. Consider the following: $(document).ready(function() { // Closing brace correctly indented $("input").focus(function() { $(this).closest("li").addClass("cur-focus"); }); // <-- I had to manually unindent this // Closing brace incorrectly indented ...