More useful JS: Prototype revisited

OK, for those of you watching from the sidelines, remember when we talked about the Prototype framework, and I said it could be done slicker? I am now correcting those little errors.

First of all, I was not using enough parts of Prototype, and so I was doing unnecessary stuff, and also, I was leaving empty `` tags in the DOM, not removing them like I should.

/* Shows the order form, and hides the button. */
function turnOnForm()
Element.toggle(“orderform”, “enablerButton”);
* Returns false if listed fields are not filled out.
function checkform(frm)
var labeltext = “Hey!“;
var fields = new Array(“nameid”,
“emailid”, “addressid”,
“zipid”, “cityid”, “phoneid”);
var we_have_an_error = false;

/* Remove the removables */
var lbls = document.getElementsByClassName(“removable”);
for (i=0; i

Published by Olle Jonsson

Human. Wears glasses and often a smile.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.