prototype

Generic way to fill out a form in javascript

I'm looking for a really generic way to "fill out" a form based on a parameter string using javascript. for example, if i have this form: <form id="someform"> <select name="option1"> <option value="1">1</option> <option value="2">2</option> </select> <select name="option2"> <option value="1">1</option> <option val...

What is the best field validation plugin for Prototype?

Not wanting to re-invent the wheel or anything, I was wondering if there's a plugin out there a field or form validation plugin that works with Prototype that you can recommend from your own experience and why? ...

Prototype click, mouseover and mouseout can't work together?

Hi, I'm trying to do a very simple button that changes color based on mouseover, mouseout and click, I'm doing this in prototype and the weird thing is if I used mouseover and mouseout, after I clicked on the button, the button wouldn't change to white, seems like it is because of the mouseout, here's my code $("izzy").observe('mouseove...

Shorten the code for a lot of buttons in Prototype

Hi, I have a lot of buttons and by clicking on different button, different image and text would appear. I can achieve what I want, but the code is just so long and it seems very repetitive. For example: var aaClick = false; $("aa").observe('click', function() { unclick(); $('characterPic').writeAttribute('src',"aa...

how to disable default context menu for certain elements in mozilla using Prototype?

I'm trying to expand navigation options of the context menu on certain elements (specifically, h1 and h2 tags) I want to prevent the browser's default action when right-clicking on those elements. I found nice information at this page. However, I couldn't find how to disable the context menu for certain elements. Does someone know how ...

How to Force Javascript to Execute within HTML Response to Ajax Request

We're using Prototype for all of our Ajax request handling and to keep things simple we simple render HTML content which is then assigned to the appropriate div using the following function: function ajaxModify(controller, parameters, div_id) { var div = $(div_id); var request = new Ajax.Request ( controller, { ...

How to add event handler with Prototype new Element() constructor?

I'm inserting an img tag into my document with the new Element constructor like this (this works just fine): $('placeholder').insert(new Element("img", {id:'something', src:myImage})) I would like to trigger a function when this image loads, but I can't figure out the correct syntax. I'm guess it's something like this (which doesn't w...

Dynamically growing an array of text inputs (HTML/JavaScript)

I'm creating a data entry app for some in-house stuff. My team needs to enter info about "items" which can have many "categories" and vice versa. I need a quick way to let them enter an arbitrary amount of categories. Here's my idea: On the item entry page, I'll have it so that initially there's one text input for "categories" and if...

Extending every Ajax.Request onSuccess event (Javascript Prototype Framework)

Hi, I have an application that uses Ajax.Request and its onSuccess event handler in lots of places. I need to call a function (that will check the response) before all these onSuccess events fired. I tried using Ajax.Responders.register with onComplete event but it fires after Ajax.Request's onSuccess event. Any suggestions? Thanks, ...

How to use javascript to swap swf in html?

Hi all, I embedded a swf in my html page, but I would like it to swap to another swf when I clicked on a button in html. I used swfobject.js to embed the swf, and I use prototype to write the javascript. I thought I can just do this $('movie').value = 'swf/bhts.swf'; alert($('movie').value); the value did change to swf/bhts.swf, but ...

How to Stop Click Event From Executing in Javascript Function?

I am trying to assign the onclick event to an anchor tag that already exists when I click on another element. However, everything I've tried seems to result in the firing of the event immediately after assignment. We're using Prototype and Scriptaculous. This is the function: <script type="text/javascript"> function loadData(step, d...

Making a drop-down list using scriptaculous and prototype's BlindDown or SlideDown effect

I'm trying to make a javascript dropdown list using scriptaculous and prototype. I know this can be done using CSS :hover pseudo-selectors, but I would like to add some additional flair to it. The problem is that while I can kind of get the dropdown/up effect working, it seems very flaky. Is there a simple way to do this, or should I sti...

Updating different divs from AJAX depending on validation errors

I have a form I am submitting via AJAX (using prototype and the built-in rails 'form_remote_tag' helper). What I would like is to update one div (a status area) if there are form validation errors but a different div (the div where the form lives) if the submit goes through sucessfully. My code looks something like this: <div id="recip...

Best way to pass JSON from Browser to PHP using Ajax.Request

Hi I have a JSON object that is a 2-dimentional array and I need to pass it to PHP using Ajax.Request (only way I know how). ...Right now I manually serialized my array using a js function...and get the data in this format: s[]=1&d[]=3&[]=4 etc. .... my question is: Is there a way to pass the JSON object more directly/efficientely?..ins...

Suggested platform/tools for rapid game development and game prototyping

What platforms and tools should I use for rapid game development and prototyping? Say that I have an idea for a simple game or a game mechanic that I want to try out, what are the best tools for quickly creating something playable that I can experiment with to try out the idea? The platform does not necessarily have to be easy to learn...

How to Add Event Handler with Arguments to an Array of Elements in Javascript?

I have a three-step process that is entirely reliant upon JavaScript and Ajax to load data and animate the process from one step to the next. To further complicate matters, the transition (forward and backward) between steps is animated :-(. As user's progress through the process anchor's appear showing the current step and previous step...

Script.aculo.us Sortable onUpdate problem in IE.

I'm working on a project where I am using a script.aculo.us Sortable object. It works nice and fast in Firefox and Chrome, but in IE it is incredibly slow whenever I drop an element. I've done a little checking, and it turns out that in IE, the "onUpdate" callback function gets called about 8 times every time I drop. Normally it is s...

How to display loading status with preloader and multiple images?

I am building a slideshow with a few hundred images and would like to build a nice loading bar, so the idea was to preload the images using JavaScript, then initialize the rest of the UI afterwords. Preloading the images is not a problem, but getting the browser to update the status as things load is. I've tried a few things, but the br...

Display Current Time each minute (with Prototype's Ajax.PeriodicalUpdater ?)

I have an app that display's the current time when a page opens. I would like that time to update every 30 seconds. I've read about prototype's Ajax.PeriodicalUpdater and it seems to be an answer. This is how I achieve the static time display on page load with php: <tr> <td> <input class="standard" type="text" name=...

JSON to string in Prototype

The people on this website seem to know everything so I figured I would ask this just in case: Is there a method/function in prototype that converts a JSON object to a string that you can store in a cookie? If not,..i'll just use another external library. Thanks, Andrww ...