First of all, you're referring to "JavaScript," which is very, very different from "Java."
Now, this can be done, but not reliably. (For instance, if the user has JavaScript turned off, they'll be able to bypass it.) Since it can't be done reliably, you will need some sort of server-side script to give them an error if they select an illogical set of options. Nonetheless, the following techniques will help to guide users who have javascript turned on:
1. You can gray-out the buttons, at least in Internet Explorer. If you have a reference to the button (for instance,
var disallowedbutton = document.myformname.mybuttonname;
), then you can disable it as follows:
disallowedbutton.disabled = true; // or false, depending.
2. If that doesn't work in all browsers, you can completely visibly remove the button from the page:
var disallowedbutton = document.myformname.mybuttonname;
//either:
disallowedbutton.style.visibility = 'hidden'; // hides the button but it still takes up space
//disallowedbutton.style.visibility = 'visible'; // undoes the previous line
//or:
disallowedbutton.style.display = 'none'; // hides the button and it no longer takes up space
disallowedbutton.style.display = 'inline'; // undoes the previous line
But again, these methods are not foolproof, and shouldn't be relied on to keep the user from doing something he shouldn't be able to do.