javascript

Currency Math in JavaScript

Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem: I need to subtract one number from the other. The problem is that the numbers have a dollar sign (because its money), therefore jQuery is treating them as strings instead of numbers. I have created two variables - toalAssets and totalLiabil...

How does Google Wave & iGoogle prevent XSS by a widget?

Hello, If you've used Google Wave or iGoogle you have probably seen that you can insert widgets that are made by third parties without approval. My question is: How does prevent the widge from performing XSS or steak cookies? Are the widgets loaded in an <iframe>? If yes, then what prevents them from redirecting you to another page? Th...

How do ansynchronous methods work

Hello, I'm wondering if anyone can help me understand some asynchronous javascript concepts... Say I make an asynch ajax call like so: xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange= myFoo; xmlhttp.open("GET",url,true); Here is my callback function: function myFoo() { if (xmlhttp.readyState==4) { if (xmlhttp.stat...

adding an uncertain number of fields using javascript

I'm new to javascript and a novice programmer, so this might be a really easy question to answer. I would like to loop over the values of x number of fields and add them up to display the sum in a final field. I can perform this function if I explicitly call each field, but I want to abstract this so I can deal with a flexible number of ...

JQuery: json to object?

var gallery = new TGallery([[{"image":{"updated_at":"2010-03-20T00:00:00Z","title":"dfgdfg","spam_reports":0,"by_profile_id":1,"comment_count":0,"id":1,"description":"htt","on_type":"profile","adult_reports":0,"on_id":1,"created_at":"2010-03-20T00:00:00Z"}]]); Then in the TGallery class I would like to convert the json object to a js o...

need help with jquery selectors

I've got code like that: <ul class="gallery_demo_unstyled"> <li class="active"><img src='001.jpg' /></li> <li><img src='002.jpg' /></li> <li><img src='003.jpg' /></li> <li><img src='004.jpg' /></li> <li><img src='005.jpg' /></li> <li><img src='006.jpg' /></li> </ul> <div class="Paginator"> <a href="....

Dynamically manipulate php cookies with javascript/jquery

Hi guys, I'm currently building a dynamic menu bar(vertical and horizontal). in the default position its vertical. the user have the option to show the horizontal position and hide and vertical. I am currently doing that with javascript/ jquery. in order to keep the menu bar in the horizontal position i am keeping a count with a cookie....

Animation with Initial Velocity

I've been trying to solve this problem for a number of days now but I must be missing something. Known Variables: vi = Initial Velocity t = Animation Duration d = Distance. end velocity should always be zero The function I'm trying to create: D(0...t) = the current distance for a given time Using this information I want to be able to ...

convert a number to the shortest possible character string while retaining uniqueness

I have a list of digits number, say "123456", and I need to map it to a string, any string. The only constraint on the map functions are: each list of digits number must map to a unique character string (this means the string can be arbitrarily long) character string can only contain 0-9, a-z, A-Z What map function would produce the ...

General Web Programming/designing Question: ?

hi, I have been in web programming for 2 years (Self taught - a biology researcher by profession). I designed a small wiki with needed functionalities and a scientific RTE - ofcourse lot is expected. I used mootools framework and AJAX extensively. I was always curious when ever I saw the query strings passed from URL. Long encrypted qu...

:focus in IE not working

Hey, I've created a site with CSS that requires the :focus pseudo class. I change the 'filter' and 'background-image' effects when a textbox is selected (i.e. has focus). This works in Chrome/FF, but doesn't seem to work in IE8 (and, presumable, previous versions if IE). I tried to look for answers, and have tried to use :active - but ...

Is there a security issue with using javascript to manipulate cookies?

Hey guys, another quick question for the experts. I have an alert box that displays updates processed in php to the user just like this site. I want to make it so that if the user closes the box, then it will not pop up for another 5 minutes (unless they check the messages then it will not pop up because the entries that cause the pop up...

funny behavior of jquery code

Funny thing is that if i delete the comment for alert(data[i].id) the code works. As it is in the example, the string is not concatenated thus i have no options in the select box. Hints? Help? Re-edited so that you guys can see the whole method function socialbookmarksTableData(data) { var toAppend = ''; var bookmarkingSites = ...

Formatting and pretty printing dates with jquery

I need to display dates in a couple different ways in an app built with jquery. In some situations, I need the typical "yyyy-mm-dd hh:mma" type of formatting, with all of it's different permutations. In other cases, I need to show dates "pretty printed" similar to how StackOverflow does them: 5 seconds ago 12 minutes ago 3 hours ago y...

How do I change the mouse cursor when I mouseover on a particular area in Google Map v3?

Using the Google Maps API v3: How do I change the mouse cursor when I mouseover on a particular area? ...

Manipulate highlighted text with Javascript

HI, I'm trying to develop some code in Javascript that adds highlighted text to a class. What I want to achieve with this is the ability of text highlighting with a custom color. I want it to kind of look like the following: window.getSelected = "<span class=\"highlighted\">" + window.getSelected + "</span>" after the above code is e...

How do I reset the scale/zoom of a web app on an orientation change on the iPhone?

I'm having the same problem that a couple of others have had with getting the correct behavior in a web app on an orientation change, and there doesn't seem to be an obvious solution - I've seen this question asked a couple of times on Stack Overflow and no one's yet been able to answer it. When I start the app in portrait mode, it work...

Use javascript to get the style of an element from an external css file

I have a html like this: <html> <head> <link rel="stylesheet" type="text/css" media="all" href="style.css"> </head> <body> <div id="test">Testing</div> <script> alert(document.getElementById('test').style.display); </script> </body> </html> The style.css: div { display...

is there any reference you consider a basic ajax reference to create a popup menu ?

i would like know some reference. I know i can googling it. but prefer from your point of view and your understanding what is the basic one...thanks ;D ...

Programmatically enable Javascript in Blackberry browser (not in Browser Field)

Is there a way to programmatically enable Javascript in Blackberry Browser? In my application I have to open an URL in Blackberry browser but for that I need to first enable Javascript. I do not wish to use Browser Field as the content displayed in it doesn't look good. Any help in this regard will be highly appreciated. ...