javascript

PHP and jquery, help passing PHP variable to javascript

Hello, I am trying to allow the users of my website, to upload images and then select one to be a back image, the uploading works fine, but I have a problem in my controller or view I think, i would appreciate it some could help me out, VIEW: <div id="background-select"> <?php $count = 0; if(isset($special)) { foreach ($s...

What is the fastest way to move a rectangular (pixel) region inside a HTML5 canvas element

I want to implement vertical scrolling of the contents of a HTML5 canvas element. I don't want to render the whole content again. Instead I would like to move the whole content down/up and only render the area, which has been scrolled into view. I experimented with the getImageData and putImageData functions but in my tests they are alm...

How to use onchange in HTML

Hello, I have two text box in html ie: <input type="text" value="" id="a" name="a" /> <input type="text" value="" readonly="true" id="b" name="b" /> Now if i enter only a number in element id "a" then the product of inserted number by 2 will be appear in element id "b". Like: While i m typing a number let say 11 in element "a" then ...

javascript single double quote problem

Hello guys, I have this rather classic problem when interacting with databases of handling single quotes and special characters. In PHP I am escaping the single quote with another single quote and regex syntax characters with preg_quote and they are working as a pro. The problem is with javascript, there are some points in my s...

2D array JSON deserializes into a string not an array

How can I deserialize the string of JSON below into a two-dimensional array object using JavaScript? If I use JSON.parse or eval it gets converted to a string. I'm using Douglas Crockford's JSON library. [["Apples", "21529", "22457"], ["Apricots", "12547", "12559"]] ...

Dynamic JavaScript If Statement

In PHP I can do: // $post = 10; $logic = >; $value = 100 $valid = eval("return ($post $logic $value) ? true : false;"); So the statement above would return false. Can I do something similar in JavaScript? Thanks! Darren. ...

Create dynamic inline stylesheet

What is the best way of creating dynamic style tags using js and/or jQuery? I tried this: var style= jQuery('<style>').text('.test{}'); This works in FF but pops an error in IE7 "Unexpected call to method or property access." var style = document.createElement('style'); style.innerHTML='.test{}'; Gives the same error. It doesn't m...

Mootools - selecting a DOM element by its classes

I use MooTools, and I need to find the element which has both classes "a" and "b" (the innermost div in my example below). The HTML structure is: <div class="a"> <div class="otherclass"> <div class="b"></div> </div> </div> In jQuery it's $("div .a .b"), as far as I know. What's the mootools syntax? I've tried $$("div ....

edit a html table cell

I have a table with a few rows... I select a row and click on modify and I should be able to make all the cell of that row editable... how does one do to make a cell editable in javascript? Is it better to use Jquery and how ? ...

Problem Using Sifr - Invisible Text

Hello, I'm trying to use sIFR for the first time and I have bit of a problem. Without the sIFR CSS included (I'm trying to get everything right first) the selected element just gets pushed down to make way for the sIFR text, but it's not visible. Any idea what could be going wrong? Cheers, Jon ...

why is ExternalInterface available inside Flash ide

hey I'm trying to build this simple debugger class so i can see flash vars inside the browser console and if I'm testing it inside the flash ide i will get the good old tracer. But for some reason ExternalInterface.available returns true inside the Flash ide!? package libs { import flash.external.ExternalInterface; public class...

javascript require/include

Hi, I wrote a script like that: NS.load = function(src) { var script = document.createElement("script").setAttribute("src", src); document.getElementsByTagName("head")[0].appendChild(script); } It loads files but I can't reach functions and variables defiened in other files. //js/main.js var qux = {name: "name"}; NS.load("js...

Javascript - how to find hebrew?

hi, i"m trying to fint if a string starts(first letter) width an RTL language/ hebrew. any ideas? ...

can search engine read jquery action

i want to popup a div with iframe content. dose search engine can read this when i'm using jquery to perform that ? OR is there a way to detect search engine in server side and remove the option of this popup ? thanks ...

Why does a parameter of a JavaScript function return 'undefined'?

I'm trying to write a simple a JS function which randomly rotates the background-image of a CSS block per 1 second. I want to add the name of the block and the number of images from paramaters, so the function can be as flexible as possible and a I can call multiple instances of it on one page. The problem is that I get 'nameofparamter u...

How keep-alive of HTTP can/is play role in AJAX application

"keep-alive" its there in HTTP. Some says it good should be used, but i am unable to get to any conclusion. So please provide your input/answer/views so i can get some ground for this, What it does? Scenario where it should and should not be done? How it can make AJAX application better ? Risks DO's and DONT's if any? Thank you all f...

Chrome and Safari XSLT using JavaScript

I have the following code that applies a XSLT style Test.Xml.xslTransform = function(xml, xsl) { try { // code for IE if (window.ActiveXObject) { ex = xml.transformNode(xsl); return ex; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && doc...

Make a YUI asyncRequest call which is not async

I want to make a YAHOO.util.Connect.asyncRequest call, which not is async. Just like open(method, url, async) where false is passed by async. I can't find a "syncRequest" in the Connect class. Is this possible using YUI 2? I tried without YUI instead: function createRequestObject() { var ro; // Mozilla, Safari,... if (win...

Adding Elements inside another DOM element in MooTools

Can I add an object of Elements inside another DOM element using grab or inject or anything else? There are two items in the object, both of type Element that are created through Javascript: var firstElem = new Element("div", {text: "something"}); // <div>something</div> var secondElem = new Element("div", {text: "else"}); // <div>...

Jquery animation using animate()

Hello, I am trying to animate background images on my site, when a background image is selected I want it to slide in from the left and push the old background out of picture, can anybody help with the code as the stuff I have written does not work, <script type="text/javascript"> $("a.background_btn").click(function(ev){ ev.pre...