javascript

using reCAPTCHA with ajax....javascript loading problem

Hi, I trying to implement reCAPTCHA in one of my forms,...but i am using ajax as the submission. (More specifically the prototype ajax.updater) Once I submit and error check my form I try to load the reCAPCHTA widget thingy (in my updated div element) which basically just calls a javascript file like so: <script type="text/javascript"...

Keyboard shortcuts with jQuery

How can I wire an event to fire if someone presses the letter 'g'? (where is the character map for all the letters BTW?) ...

Left click, right mouse button same in IE and Firefox??

Are left click, right button of mouse in IE, is same in Firefox?? Can anyone specify proper method to handle them efficiently using Javascript?? ...

How can I create an element that flips between two values on click?

Given two spans like this: <span>Click for info</span> <span style="display: none">Here is a big long string of info blah blah</span> ...I'd like to have an onclick function attached to each so that the visitor sees "Click for info", and then when they click it, the first span is hidden and the second is unhidden. And, of course, when...

Get elements just 1 level below the current element by javascript

I need to access the DOM tree and get the elements just 1 level below the current element. Read the following code: <div id="node"> <div id="a"> <div id="aa"> <div id="ab"> <div id="aba"></div> </div> </div> </div> <div id="b"> <div id="ba"> <div id="bb"> <div id="bba"></div> ...

Regex: problem creating matching pattern

Having some problems figuring out the regex to match this: function Array() { [native code] } I'm trying to only match the text that will occur where "Array" is. ...

Run PHP class from JavaScript

I need to fire a php class from a javascript function. code: <input type="button" name="Submit" value="Submit" class="opinionbox" onclick="verifyControl('<?=$control_no?>')"/> function verifyControl(rNo) { Cont_no=document.getElementById("ContNo").value; if(rNo==Cont_no) { frames['frame1'].print(); showPage('payment'); }...

PHP Embedded in Javascript

Hi friends, in my project I have the situation like this. <script language="JavaScript"> function fonsubmit() { alert('Out side PHP'); //Here the php code starts include("customerpage.php"); $cc="us"; $clang="en"; $cpath="us"; some coding goes here...... Php ends here } </script> But it shows Object e...

Truncate leading zeros of a string in Javascript

Hi all, I have a textbox in Javascript. When I enter '0000.00' in the textbox, I want to know how to convert that to only having one leading zero, such as '0.00'. Please anybody help me in this regard. Thanks in advance.. raja. ...

How can I add properties to an object in IE6?

I've got a particularly tricky problem using AJAX, which works fine in IE7 and Firefox, but not in IE6. I have a very simple home-grown AJAX framework, which requires that I extend the XMLHttpRequest object (or in the case of IE, the XMLHttpRequest ActiveXObject) by adding a couple of properties. Relevant section of code is as follows: ...

XSS without a server being involved - is this dangerous?

We've been discussing about a client-only solution in javascript that provides means for a site visitor to annotate a page for printing and it's exploitability in terms of XSS or similar attack vector. Rationale: There's a potentially long process choosing what data to display. In order to document the steps taken, a textarea (without ...

Very strange JavaScript error in IE7

I am developing JavaScript chat. I have done the prototype, and it seems to work pretty well. But our client says that it doesn't work. We both use IE7 on PC, and try to run the same JavaScript code. I have no idea about the reason. On my client's machine there is "object is expected" error. I have thought about security restrictions, an...

parseInt alternative

Firstly - my description ;) I've got a XmlHttpRequests JSON response from the server. MySQL driver outputs all data as string and PHP returns it as it is, so any integer is returned as string, therefore: Is there any fast alternative (hack) for parseInt() function in JS which can parse pure numeric string, e.g. var foo = {"bar": "12...

Object Focus problem with Safari and Chrome browsers

I have the following javascript being called to request a focus when page is loaded. This code works 100% OK with Firefox and IE7, but Chrome and Safari do not seem to move the focus at all. How to make it work with all browsers? document.getElementById("MyFlashFile").focus(); ...

Fix for background-position in IE

I get this problem in IE7 when running a piece of code that uses jquery and 2 jquery plugins. The code works in FF3 and Chrome. The full error is: Line: 33 Char: 6 Error: bg is null or not an object Code: 0 URL: http://localhost/index2.html However line 33 is a blank line. I am using 2 plugins: draggable and zoom. No matter what...

jQuery tooltip + ajax content

I'm trying to implement a simple rollover tooltip for images on a page where when you roll over an image, you get a little tooltip window and have the contents loaded from a database via AJAX. I can hack this together quickly but I wanted an elegant way of doing this without using any inline JS. So my question is: If I capture the rol...

What would the Javascript look like for an AJAX commenting system?

I am trying to create a commenting system whereby admins are able to moderate comments and users are able to post comments all in the one page load. I have all the backend knowledge on how to delete the comments, but I really have to know how the new comments could be loaded from the database and shown on the current page. Edit: More sp...

Best way to create a dynamic Select (Dropdown) list?

I'm using jQuery and jqGrid. I'm trying to populate a select list dynamically, one for each row and I need to add a click event to it. When the select list is being populated I grab the index of the item I want selected, and then after all items are add I'm trying to set the selected item. I've tried $("#taskList")[0].selectedIndex ...

How can I delete all cookies with Javascript?

I have written code to save the cookies in Javascript. Now I need to clear the cookie irrespective of values that I assigned. Are there any script modules to delete all cookies that were generated by javascript? My Sample Code: document.cookie = 'ppkcookie2=another test; expires=Fri, 3 Aug 2001 20:47:11 UTC; path=/' function create...

What is the best way to post an image to a server using AJAX?

I want the user to post an image to the server and load it back into the page when its ready, all this without leaving the page. What is the best way to do this? ...