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>
Showing posts with label prototype. Show all posts
Showing posts with label prototype. Show all posts
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
Simple Form Validation with Prototype
1: <script src="prototype.js"></script>
2: <script>
3: //example: checkForm('myForm');
4: function checkForm(frm)
5: {
6: allFields = Form.getElements("myForm");
7: for(i=0;i<allFields.length;i++)
8: {
9: if(allFields[i].value == "")
10: {
11: $(allFields[i]).addClassName('error');
12: } else {
13: $(allFields[i]).removeClassName('error')
14: }
15: }
16: }
17: </script>
Subscribe to:
Posts (Atom)