PDA

View Full Version : JS reference (not in head)!



djlebarron
18 Dec 2008, 08:35 PM
I just discovered that I don't have to put my <script src="comm6.js" type="text/javascript"></script> in the head of my document to make it accessable to an OnClick. I can put it in the body before the OnClick and it works like a charm. How 'bout that!

I've got quite a HUGE number of includes. I needed to give a unique js script to each individual include depending on the varied number of checkbox options in each include. The includes (3500+ of them) will have from 2 checkbox options to 132 checkbox options. The includes initially display with the "choose all" box checked. That's so the processed form's output page will display the results with all of the parameters (choices) included if the user doesn't do anything but click the "view" (submit) button. The JS script removes the "checked" from the "choose all" box when any of the other boxes are checked. It also puts the "checked" back in the "choose all" box, and removes the checks from all the other boxes, when the user attempts to check all the choices (other than "choose all" of course). And it displays the alert "You must choose at least one option" if the user removes all checks from all boxes. And after the user closes the alert (by clicking "OK"), it puts a check back into the "choose all" box. Kind of like starting fresh.

I didn't want to have to reference to one extremely huge js library file on this particular php page. Not having to put my reference(s) in the head will enable me to put the unique references in the appropriate includes. That way I'm only referencing one small js file per include/page.

I'm such a happy camper about this, I just had to post it.