Archive for JavaScript

Form inputs and their behaviors

So looks like someone needs to play a bit more with their form inputs. Marko reports that when he changed his form from:

<input type="button" />

to:

<input type="image" />

His forms started getting submitted automatically when clicking the image button. But yeah, that’s how it’s supposed to work. If that button is supposed to be your main “submit” like button on your form, then change your JavaScript code to trap the onSubmit event and return false to it. As in:

<form method="post" onSubmit="javascript:return handleXHR();"></form>

Then inside that function you just do “return false;” to stop the form from being submitted.

Web 2.0 my ass

So I’m playing with script.aculo.us for a side project, trying to create a <DIV> that will slide into and out of view, but something is not working quite right. When I use the Effect.SlideDown() and then Effect.SlideUp() repeatedly, it will continuously grow the height of the element.

Everything seems to be fine, the documentation tells me that I’m doing the right thing, which is to create two <DIV>s, but somehow it doesn’t work on my version, but it works perfectly at the demonstration page on the script.aculo.us website. Even the bug entry about it says that in order to fix it, I should simply use block level elements, which I’m doing.

So here’s the fix for this if someone else ever hits the same problem:

Don’t use:

  </div>
</div>

like a real monkey should to make your HTML code easier to read, but rather this:

</div></div>

Doing that fixes this apparent bug, which makes no sense to me.

« Previous Page « Previous Page Next entries »