javascript

scripty (scriptaculous) draggable onEnd not executing in Safari

hey all, i've created a very iphone-y slider element that is both restricted in overall movement horizontally (0-400px and it does not move vertically) and "snaps" to either side of the 400px "container" when it has passed the 200px mark and the drag has ended. It works perfect in firefox. In Safari, the onEnd function that positions th...

Search in html Javascript

I have the below html code, also i will have a textbox for entering the keyword, What i want is while the user writing in this textbox the javascript search in this html code using the FirstName and LastName , and while comparing items, if an item didn't match i want to display:none its container div. How can i do that using JS and work ...

How do I add/remove a class in a <div> when it already has classes

Hi, How do I add/remove a class from a div when it already has one or more classes? <div class="class1 class2" id="id1">some text</div> $("#id1").toggleClass("class3"); // doesn't work $("#id1").toggleClass(" class3"); // doesn't work Do I have to parse the string? ...

Seeing strange behavior on IE6 - I'm clueless

I use the following to implant a script into random websites: (added by webmasters just before /body ) <script type="text/javascript"> var xHost = (("https:" == document.location.protocol) ? "https://" : "http://"); document.write(unescape("%3Cscript src='" + xHost + "domain/script.js.php?u="+encodeURIComponent(window.location.host)+"' ...

BlockSchemes in JavaScript

I need visualizer of algorythmes created in JavaScript. Like BlockSchemes, mostly with If and Statement blocks. That could be moved, resized, connected with arrows. Anybody saw such open source projects? ...

Get next/previous element using Javascript

How do I get the next element in html using javascript? Suppose I have three divs and I get a reference to one in js code, I want to get which is the next div and which is the previous. ...

I want to scan 2 datum and see if it has relevancy or not.

So I want to scan 2 Datum, these are texts, then I will rate it if it has relevancy. Example: Data: individual facts Data: statistics, items of information individual facts This is my JS code that will scan the whole webpage: var listitem, thislist; var itemname = new Array(); listitem = getElementsByClass('Forwards'); for(var i = ...

Best way to track onchange as-you-type in input type="text"?

In my experience, input type="text" onchange event usually occurs only after you leave (blur) the control. Is there a way to force browser to trigger onchange every time textfield content changes? If not, what is the most elegant way to track this “manually”? Using onkey* events is not reliable, since you can right-click the field and ...

Best way to display Javascript/Div based hover windows?

I'm talking about the Ibox sort. I.e, user clicks a link and a small javascript based div hovers up containing a small form or such. I will want to give users a <script> tag which they would place in their website. Then, they would put the required javascript function in their <a href> tag which they want to use for displaying the form....

How to load up CSS files using Javascript?

Is it possible to import css stylesheets into a html page using Javascript? If so, how can it be done? P.S the javascript will be hosted on my site, but I want users to be able to put in the <head> tag of their website, and it should be able to import a css file hosted on my server into the current web page. (both the css file and the j...

how to put html content over flash when wmode=window?

Is this even possible? The situation is, I don't control the embedded flash, and I have no way of knowing whether it is embedded with wmode=tranparent/opaque or wmode=window. This means in the first 2 situations I can put my html content on top, just by using z-index, but in the last situation (wmode=window) I have no control. Does any...

Javascript OO question

So I want to build a form validation class/object in javascript. The way I see it working would be something like this: var form=new Validation(); form.addField("name","Your name","required"); form.addField("email","Email Address","is_email"); ......... form.validate(); I was thinking that the validation class would be defined someth...

Newbie: hanging browser on function call

I just started learning JavaScript and am wondering why this simple snippet hangs when I click on the "Call function" button. What am I missing? <html> <head> <script type="text/javascript"> function myfunction() { document.write("hello"); } </script> </head> <body> <form> <input type="button" onclick="myfunction()" value="Call fun...

Associative arrays in javascript

I have this object: function formBuddy() { var fields = new Array(); var labels = new Array(); var rules = new Array(); var count=0; this.addField = function(field, label, rule) { fields[count] = field; labels[field] = label; rules[field] = rule; count = ++count; } } Its use...

passing values to fields using javascript

Hi all, I'm currently building an app where i need somewhat of a lookup control. How this would work is that there is a texbox with a lookup button on a form. The user can either type in a value for the textbox or can choose the lookup button. When the user presses the lookup button a javascript window with a gridview and a list of colu...

Submitting an ordered list to a server

To teach myself Javascript, I'm trying to make a web page that gives users a list of items (e.g. foods), asks them to sort these foods from favorite to least favorite, and submit the data when they're done. Using jQuery sortables seems like a good way to do this. However, I'm not sure how the data submission should happen. Here's what I...

How to create gradient object with Raphael

Hi, I was trying to use Raphale JS graphics library. I would like to use the attribute gradient which should accept an object. Documentation says to refer to SVG specs. I found the gradient object in SVG, for instance <linearGradient id="myFillGrad" x1="0%" y1="100%" x2="100%" y2="0%"> <stop offset="5%" stop-color="red" /> <stop offset...

constructing javascript variable names at runtime

someFunction(link) { someOtherFunction('div' + link); } By calling someFunction("Test"), the string "divTest" gets passed to someOtherFunction(). But I want the value of the variable "divTest" to be passed. How can that be done? ...

Regular Expression: Allow letters, numbers, and spaces (with at least one letter or number)

I'm currently using this regex ^[A-Z0-9 _]*$ to accept letters, numbers, spaces and underscores. I need to modify it to require at least one number or letter somewhere in the string. Any help would be appreciated! This would be for validating usernames for my website. I'd actually like to support as many characters as I can, but just wa...

How can I unobtrusively disable submit buttons with Javascript and Prototype?

So I found this recommendation, but I can't quite seem to figure out how. This is the code I originally started with: function greySubmits(e) { var value = e.srcElement.defaultValue; // This doesn't work, but it needs to $(e).insert('<input type="hidden" name="commit" value="' + value + '" />'); // This caus...