Page 1 of 1
How would I disable a button?
Posted: Wed Jul 18, 2007 3:45 pm
by legend986
I have a series of radio boxes on a php page. Depending on some conditions, I'm disabling them or enabling. With this, a situation may arise where all the radio boxes are disabled. How would I disable the submit button when all the radio buttons are disabled?
Posted: Wed Jul 18, 2007 3:48 pm
by Ambush Commander
Set the disabled attribute on the submit button.
Posted: Wed Jul 18, 2007 3:50 pm
by legend986
No, i mean how would i check if all the radio boxes are disabled? If one or two are disabled, I don't want to disable the submit button...
Posted: Wed Jul 18, 2007 3:53 pm
by feyd
PHP has no control over this stuff. Moved to Client Side.
Posted: Wed Jul 18, 2007 3:54 pm
by legend986
My bad logic.. Sorry again

Posted: Wed Jul 18, 2007 4:14 pm
by legend986
Got it!
Code: Select all
<script language="javascript">
window.onload = function(){
var count1;
count1 = 0;
for(i=0;i<document.course.course_id.length;i++) {
if(document.course.course_id[i].disabled == true)
count1++;
}
if(count1 == document.course.course_id.length)
document.course.course.disabled=true;
}
</script>
Thank You
