Nduul wrote:
"RobG" <rg***@iinet.net.auau> ha scritto nel messaggio
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
When you change the the table to visible or hidden, also change the
select's disabled attribute to false or true respectively.
can you explain me how to do with the script of that page? I have many
select in each table
thanks
Firstly validate your page, it has very old and depreciated code.
Here's your script with comments inserted:
<script language="JavaScript">
The language attribute is depreciated, type is required
<!--
HTML comments inside script tags are totally out of date, do not use them.
function visualizza(quale) {
document.getElementById('tabella'+quale.name).styl e.display =
(quale.checked?"inline":"none");
Break up long lines, if only for readability and test features before
trying to use them.
When using the display attribute to hide or show parts of a table,
switch between '' and 'none'. '' will return the table to it's
default or whatever has been set in CSS somewhere - it almost
certainly should not be 'inline'.
You should also test to ensure features are supported before
attempting to use them - in this case, getElementById and the style
object. Read the FAQ if you need some help with supporting older
browsers.
<URL:http://www.jibbering.com/faq/>
}
//-->
Ditch comments.
</script>
Below is your script tidied up. There's an extra function that will
disable any input control in the table - if you add other types of
control, you'll need to accommodate them too. I've made an assumption
that if getElementById is supported, then so is getElementsByTagName.
But you still have a usability issue - when the page loads, your
checkboxes are unchecked. When they are first checked, the script
makes them visible so nothing appears to happen. Only when they are
unchecked again do they disappear.
I'll leave fixing that (and other related issues) to you.
<script type="text/javascript">
function visualizza(quale) {
if ( document.getElementById ) {
var t = document.getElementById( 'tabella' + quale.name );
if ( t.style ) {
if ( quale.checked ) {
t.style.display = '';
disableControls( f, false );
} else {
t.style.display = 'none';
disableControls( f, true );
}
}
}
}
function disableControls( f, flag ) {
var fc = f.getElementsByTagName('input');
for (var i=0, j=cont.length; i<j; i++ ){
fc[i].disabled = flag;
}
}
</script>
--
Rob