javascript

Sending data with an event listener

I have a predicament: I want to send some data with an event listener but also be able to remove the listener. Here's the standard closure approach... var fn = function(e){method(e,data)}; el.addEventListener('click',fn,false); el.removeEventListener('click',fn,false); and you could remove the event, just fine. But say, the element wa...

new value overwriting the previous values

Ok so i have this javascript function getpreconfigproducts(str1,str2) { var url="ajax_preconfig_products.php?"; url=url+"id="+str1+"&cid="+str2; xmlHttp = GetXmlHttpObject(stateChangeHandler); xmlHttp_Get(xmlHttp, url); return false; } and it calls this php <?php if($_GET['id']!='') { $sql="SELECT * FROM productinfo WHERE Product...

Show clickable thumbnails that load in same page

The task: present a series of images on a corporate intranet web site to users for viewing. I hacked together some javascript to show the list of images with thumbnails, and each image is clickable and takes you to the large image, but then you have to hit back to go to the next image, and I'm being asked to provide some next/previous f...

javascript document.cookie missing some pairs

hi all, my script set up like 10 cookies and the browser successfully saved them, but document.cookie only retrieves 9 pairs, the missing pair is as follow: auth:4ae9Mq1j6tjt7dV6kV6A0piHB6NnNjijBmecax9mA8cfDpSs6pnAcD7H1%2FUqWMIIB%2BbgtKIJ2w1L2GnXkgV2 what happened? is there a character limit in document.cookie? the cookie domain is the...

Opening a bookmarklet in a sidebar--having it close (through javascript?) after the bookmarklet runs.

Can I have a bookmarklet run (javascript) and close the window (in this case actually sidebar) at the end of the script? I've been reading around and haven't found out if it isn't possible, but it looks bleak. (>_<) If not through a sidebar, could I do it with a tab? ...

how do i extract the part between the brackets in javascript regular expressions: answer_postal_address[address]

how do i extract the part between the brackets in javascript regular expressions: answer_postal_address[address] I tried this: /^\w*/g which works but i wasn't sure if this was correct... ...

document.getElementById('id') is null javascript error

For some reason I get an document.getElementById('id') is null JS error on line 7 with the following markup and script: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Quadratic Root Finder</title> <script> document.getElementById('calculate').onclick = function calculateQuad() { ...

Load .NET Resources Client-Side on each request

I have the following JavaScript snippet: <script type="text/javascript"> var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_beginRequest(ajaxBeginRequest); prm.add_endRequest(ajaxEndRequest); function ajaxBeginRequest(sender, args) { $.blockUI({ message: '<h1><img src="/images/ajax_loading.gif" /> ...

javascript onclick event handlers not functioning properly

For some reason, my onclick javascript event handlers are not functioning properly. Here is my markup, script and style: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Quadratic Root Finder</title> <script> document.ready = function() { document.getElementById('calculate')....

How to bold keyword in php mysql search?

I want want my output like this when I search a keyword like "programming" php programming language How to do this in php mysql? Any idea? ...

Check for focus event on a particular input box

Hello, Is there a way to know whether the current input box is focused using javascript (not using onfocus event, more of an if statement to loop through a list of input boxes and know which input box is in focus) ? Basically i have a column input boxes and want to highlight the backgroud color of the current input box being edited. My...

Help correcting bookmarklet to open new Gmail compose window

Hi, I'm trying to configure a bookmarklet to compose a new message from my Gmail account in a new window. The problem is that I always get a scroll bar on the right hand side. Here's what I'm using right now. javascript:(function(){ window.open('https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;shva=1','Compose Gmail'...

Why doesn't keypress handle the delete key and the backspace key

I'm not asking this because I need a work-a-around. I have one that works fine, but I want to know WHY it doesn't. Is this bug in javascript (or JQuery because I was using the JQuery .keypress handler) or is there a specific reason why this is so? Thanks in advance. ...

Development VPS where environment (Ruby/Rails, Javasciprt/Node.js etc) is pre-installed?

Until now I'm setting up my own development environment with Vagrant/VirtualBox/Chef (Ruby). I wonder if there is a hosting company that provides pre-configured VPS for... Ruby/Rails Javascript/Node ...letting me just choose what I want to have installed and also which linux packages I would like to install in each VPS. Are there h...

Manually creating a javascript event object

Say I have the following code: $('#someid').click(function(event) { myFunction(event); }); function myFunction(event) { // do something with event } And I would like to test myFunction() with an eval statement, without doing something like using eval('$("#someid").click()'); Is there a way to manually create an event object in ja...

JavaScript simple "error-handling" by replacing NaN with conditional

I was wondering how I can detect false input type and instead of presenting the user with NaN, have a logical piece of information be displayed. Here is my code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Quadratic Root Finder</title> <script> window.onload = function() { document.getE...

Javascript question

John Resig wrote a nifty Class function, swanky. I'm trying to figure out what is going on, and have pretty much everything figured out except a single line: fnTest = /xyz/.test(function () {xyz;}) ? /\b_super\b/ : /.*/; A couple things immediately jump to mind, first xyz is never initialized as a variable; so why then does this work?...

Node.JS Looking for an alternative to socket.IO

Hi, I've been testing Node.JS and Socket.IO for a couple of days. I'm interested in a real-time application that's why I'm testing Socket.IO, problem is I found many problems on several browsers. Chrome always works but IE and Firefox only some times. My question is, is there a way to push information from the server to the client with...

Does mootools provide a way to fade() all elements but one?

Mootools can fade all nodes matching a selector like this: $$('#div img').fade(0.3); I need a way to skip a particular node. In jQuery-world, I'd use a not() and it would be something like this: $$('#div img').not( oneElement ).fade(0.3); But I can't find any way to exhibit similar behaviour in mootools. Anyone know anything? ...

Help with JavaScript self-extending bit adder

Hey guys, today i was inspired by a 16 bit ALU made in Mincraft to try and make my own self-extending adder. I literally started JavaScript today, and have been playing around with logic gates over the past couple days. So I am very new to this. Here is my code so far. <html> <body> <script type="text/javascript"> funct...