javascript

A very simple Jquery Question (Select multiple id's)

Hi, i am using a jquery plugin and my code look somthing like this. <script type="text/javascript"> $(document).ready(function() { $('#fileUpload').uploadify({ 'uploader': 'img/uploadify.swf', 'script': 'uploadify.php', 'folder': 'upload', 'auto' : 'true', 'cancelImg': 'img/cancel.png', 'fileDes...

Simple and general Client-side Persistence solution?

Hi all: Have to say I wish I could implement server-side persistence (i.e., session-based and/or database-based user state persistence), but unfortunately my uni's server has limited resources provided and it is really hard to implemented a Perl based session solution (CGI::Session and Apache::Session not installed, dated Perl version, ...

Javascript - Split dynamic string getting values inside brackets

I have this as data input (it's dynamic so it can be 1 up to 5 brackets in the same string) data["optionBase"] = {} //declaration data["optionBase"]["option"] = {} //declaration data["optionBase"]["option"][value] = {} //declaration data["optionBase"]["option"][value]["detail"] = somethingHere Each line comes as a string, not as an ar...

Setting header text of a DisclosurePanel dynamically while preserving the arrow icon?

I'd like to set the text in DisclosurePanel's header without having to re-construct the image/icon used by the default header. Using customHeader means the arrow-icon is lost, in other words that seems like unreasonable amount of extra work. EDIT: There's actually method for that, getHeaderTextAccessor(String) ...

Prevent memory leaks in this javascript code?

I have a Django admin page for a nested category list like this: I wrote this script to sort the list and present it hierarchically: {% extends "admin/change_list.html" %} {% load i18n %} {% block footer %} <script> (function(){ var rows=document.getElementById('result_list').getElementsByTagName('tr'), table=rows[1].parentN...

Javascript substring() trickery

Hi folks I have a URL that looks like http://mysite.com/#id/Blah-blah-blah, it's used for Ajax-ey bits. I want to use substring() or substr() to get the id part. ID could be any combination of any length of letters and numbers. So far I have got: var hash = window.location.hash; alert(hash.substring(1)); // remove # Which removes th...

Checking if a variable is an integer in javascript.

I made a form where the user inputs values for width and height that they want for the pop up window to be. I am using window.open for that. So I think I need to check if the values for width and height are integer. I have a function that checks that a variable is an integer that is... function isInteger(possibleInteger) { return...

I need to know the predefined point is in the sea or on the land

Hi, I have a system where users put some coordinates (latitude/longitude), I need to check if specified coordinates are in the sea or not. Is there any service that could give me the answer. Or is it possible to do this using google maps. thank you in advance. ...

Javascript: Get a reference from JSON object with traverse.

I need to get a reference from JSON object, the code just following: var Tree = { data: { 0: { pk: 1, }, 1: { pk: 2, }, 2: { pk: 3, children: { 0: { pk: 11, }, 1: { ...

Why i can't show/hide Html TR using jquery ?

I have the following TR in HTML and i using JQuery <tr class="RowDiv" id="tempTR" runat="server" visible="false"> <td> <div class="LabelDiv"> <div class="dfltTxtBld"> ID<span class="reqChar" runat="server" id="Span1" visible="false"> ...

Custom pagination component

I am looking custom pagination in jsf. I need this custom component as for dropdown. I have arraylist to display the dropdown values. The previous and next functions also needed. ...

Can you convert C# dictionary to Javascript associative array using asp.net mvc Json()

I recently asked this question, but after some of the responses and some research, i wanted to change what i was actually asking. i have seen a number of blog posts about sending associative arrays from javascript to C# controller action but i want the opposite. I want to return json to a client as a dictionary (from my research the ja...

Elegant way to bias random boolean

I'd like to create a random boolean in JavaScript, but I want to take the previous value into account. If the previous value was true, I want it to be more likely for the next value to be true. At the moment I've got this (this is in the context of a closure - goUp and lastGoUp are locals to the containing scope): function setGoUp() { ...

Mini image browser (like on myfonts.com)

Hi, I want to make small image browser like the one used on Myfonts.com (link) in the sidebar under "More fonts like this". I'm wondering if there is a jQuery plugin that could do that. I know that this is some kind of carousel, but I couldn't find any with this cool resize function on scroll. ...

Javascript to pre-select textarea on page load

Hello everyone, I have a page that has a textarea, when the page is loaded, I want to pre-select the textarea(like twitter.com does), so the user does not have to click on it. Do you know how to do that? Previously thanks! Rodrigo Alves Vieira. ...

JavaScript Preloading Images

Hello! Can you tell me if the function I wrote below is enough to preload images in most if not all browsers commonly used today? function preloadImage(url) { var img=new Image(); img.src=url; } I have an array of imageURLs that I loop and call the preloadImage function for each URL. Thank you. ...

HTML code strip regexp problem

In javascript, one of the popular regex is to strip out HTML tags from the text. The code for that is String.prototype.stripHTML = function () { var reTag = /<(?:.|\s)*?>/g; return this.replace(reTag, ""); }; If you try this on "<b>This would be bold</b>".stripHTML(), then it outputs as "This would ...

What would be the jQuery equivalent of this Prototype Ajax invocation?

In Prototype, this Ajax call posts its form to the server as a URL encoded string of name-value pairs, as you would find in a HTTP GET request: function doajax() { var current_req = new Ajax.Request('/doajax', { asynchronous:true, evalScripts:true, parameters: $('ajax_form').serialize(true)} ); } How would you do the same thing ...

document.obj.write() ..is it possible?

what i wanted to do is when i clicked on a checkbox it will automatically appear on a certain part of the page. i tried to give a checkbox an onclick='displayit()'/oncchange='displayit()' where displayit() is: function displayit(obj){ document.divnam.write(obj.value); } the divnam is the name of the division where i wanted the text to...

Can this Javascript be shortened with JQuery?

Hi folks, i'm checking out some newbie Google Maps API tutorial code. They have an example that says how to dynamically add some script to a page, once the page has finished loading. I'm wondering if this code can be made shorter if I use JQuery? here's the code... function initialize() { var myLatlng = new google.maps.LatLng(-34.3...