
Originally Posted by
paul_wilkins
Warning: Disabling a form field results in that field not being sent to the server. So the server will need to check if icecream has been chosen, and if it has, the server knows that the cone must also be mandatory.
Yes this is a problem 
With some help I've got the following script:
HTML Code:
<script type="text/javascript">
function observeFlavor(flavor, requires) {
document.getElementById(flavor).onchange = function(){
if(document.getElementById(flavor).options[1].selected == true) {
document.getElementById(requires).options[1].selected = true
}
}
}
observeFlavor("chocolate","icecreamcone");
observeFlavor("vanilla","icecreamcone");
</script>
However, the above script doesn't disable the field.
Maybe instead of disabling the field you make it unclickable when vanilla or chocolate, or both are selected. But when they are both deselected, the cone will be clickable again.
Would this solve the server-side problem? And could you give me an example if you know how to do this?
Bookmarks