javascript

Record User Actions Using PHP and Javascript

I am developing an online learning system (PHP, MySQL and Javascript). I would like to track what pages and how long each users spent on each page. Ideally, I would like to record this in a MySQL database. My question is 2 fold: 1. What kind of fields would I include in my db table to record multiple pages accessed? 2. Is this problem be...

Replacing quotation marks in Javascript?

For a web app I'm making, I'm going to be getting text strings coming in, occasionally which contain quotation marks. Because I am then going to be document.writing the string, they need to be changed either into apostrophes or escaped. How would I do that, because when I try it doesn't seem to work, specifically I think because the st...

Mootools image preloader - make it disappear after load complete.

Im using a preloader to load large images before I display them.. I am using this script: http://davidwalsh.name/mootools-image-preloading-progress-bar I want to make it disappear when it reaches 100% loaded. I have modified the script by adding progressBar.set(0); to the onComplete function at the bottom of the page. However, now t...

Event.observe 'change' events not being triggered in IE

The Prototype event listener I use for changes in select menus is not being triggered in IE. Event.observe('use_billing', 'change', Checkout.getBillingData); This works fine in Firefox (of course), but nothing happens in IE (of course) - I've been Googling this for some time, but I have not found a suitable solution to this problem. I...

Push method only works once unless variable is used before

This might be a weird question. Anyway, I'm working on a jQuery plugin and this is a useful piece of code for this question, note that it's not all ;) : Javascript: (function($){ $.fn.newPlugin = function(){ var ranges = [], selectableRange = this; function init(){ selectableRange.live('mousedown', func...

JavaScript: How to get value of sender input element from keyup event?

I need to capture the keyup event to provide live validation when user is typing in an input (change event fires only when the input loses focus). I am having trouble getting the edited value of the input that fired the evnt. The code also runs on timer to prevent multiple calls when user is typing (fires only every 500 ms). I have se...

How to include javascript from a CDN source using smarty

How do you include Javascript from a CDN source using Smarty? We have code such as the following for including it from a file on the web server, but I want to include it from a CDN instead. {javascript file="prototype.js" priority=20} When I access the Smarty documentation at http://www.smarty.net/manual/en/ "javascript" cannot be ...

Long held AJAX connections being blocked by Anti-Virus

Ok, this is downright bizarre. I am building a web application that relies on long held HTTP connection using COMET, and using this to stream data from the server to the application. Now, the problem is that this does not seem to go well with some anti-virus programs. We are now on beta, and some users are facing problems with the appl...

simple web-based icon editor

My web site uses 16 x 16 pixel icons (stored on the server as png files). I'd like to provide functionality for users of the site to edit these icons. My site already uses jQuery and jQuery UI, and I'm familiar with these, but any suggestions would be welcome. EDIT It seems that this is harder than I thought. I think I'm going to hold ...

Hide/Show <div> according to URL in Prototype

Hi Guys, I am trying to use the prototype framework to hide a '< div >' based on a particular URL. I don't have access to server side - so I have no choice but to do this using prototype [restriction of platform using prototype]. Wondering if someone could tell me how to do this in prototype framework ? i.e. I tried to do this but doe...

Documenting Javascript code

I'm developing a site which is growing a bit complex and so I started documenting my code. For PHP I have used PHPDocumentor; in any case it seems that any other tool (such as Doxygen) would accept the same tags. Now I want to document the JS side. I see at least JSDoc and ScriptDoc (and probably others) exist, and they accept differen...

jQuery Javascript ratings: Making the rating reappear when user takes their cursor off

I have this jQuery code that handles hovering over rating stars, when you hover they glow as they're meant to. Problem is, once you've taken your cursor out, it still displays what your cursor was on (and doesn't show the original rating). How can I make it check for when the cursor is removed, then show the original ratings? $(document...

Onclick event doesn't work when .append()

Simple example: I have html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="portal.css" /> <script type="text/javascript" src="/test/lib.js...

Writing a better jQuery plugin.

Hi, at the moment I have my jQuery plugin running it's logic in if statments. For example I have: (function($) { $.fn.myplugin = function(action) { if(action == "foo"){ } if(action == "bar"){ } if(action == "grapefruits"){ } } })(jQuery); Is there a better wa...

javascript move image within a div

hey, i have a div and and a looping move function that translates an image by 1px within the div. The width of the div is 400px; the image starts moving from right to left, but I can't figure out how to make it start appearing from behind the div border. Currently if I set a starting x-position at 405px and finishing x-position at -5 th...

Prototype find element and only perform if found

Hi Guys, Struggling a little here with prototype = I've created this function Event.observe(window, 'load', function() { if ($$('#test li:first')!=null) { $('test').down('li').down('a').update('Test'); } }); Basically, it works on pages where #test li:first is found but on pages it isn't it returns $("test").down("li") is undef...

How do I swap triangle icons when doing expanding/collapsing divs with Javascript/CSS

I have a div that I want to toggle between displaying or not when a user clicks on a piece of text. I have a javascript function that toggles a div on or off. That works fine. What I don't know how to do is to have a triangle that points to the right or down depending on whether the div is open. My HTML looks like this: <a onclick="tog...

How to redirect users based on browser language

I want to redirect users based on browser language, I figured out how to do this here, it works fine, here is the code(PHP): if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) header("location:index.php"); else header("location:http://cn.gearor.com"); The problem is I only want to redirect users from other websites or at t...

File upload using PrototypeJs method $('formId').request()

I was trying to upload file(s) using PrototypeJs request method but I failed. The code I am using, <form enctype="multipart/form-data" id="form1" runat="server" action="ajax.aspx" onsubmit="upMe(this);return false;" > If I make return true instead of false, the file is uploaded but that makes postback which I dont want as I am using ...

jQuery getting text value for a select list

I have a list like this: <select name="select_list_name" id="list_id"> <option value="">Select Option</option> <option value="value1">Option 1</option> <option value="value2">Option 2</option> ... ... </select> I am trying to get the text value of the currently selected option in a select list. I looked at this thr...