1: <script src="prototype.js"></script>
2: <script>
3: //exmaple: toggleDivs('myDiv,OtherDiv');
4: function toggleDivs(divs)
5: {
6: var divSplit = divs.split(",");
7: for(i=0;i<divSplit.length;i++)
8: {
9: var d = $(divSplit[i]);
10: if($(d).visible())
11: {
12: d.hide();
13: } else {
14: d.show();
15: }
16: }
17: }
18: //example: checkForm('myForm');
19: function checkForm(frm)
20: {
21: allFields = Form.getElements("myForm");
22: for(i=0;i<allFields.length;i++)
23: {
24: if(allFields[i].value == "")
25: {
26: $(allFields[i]).addClassName('error');
27: } else {
28: $(allFields[i]).removeClassName('error')
29: }
30: }
31: }
32: </script>
Tuesday, December 20, 2011
Toggling DIV's with Prototype
Labels:
javascript,
js,
prototype,
prototype div toggle,
prototype javascript,
toggle,
toggle div,
toggle prototype
Location:
California, USA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment