peterS.: Form Feld aktivieren/deaktivieren

Beitrag lesen

hallo Philipp, gruss capior,

ich habe auch noch ein script ausgegraben;
es muesste aber noch an "document.getElementById"
angepasst werden - ACHTUNG: hab das teil nur fuer
die dose geschrieben - aber vielleicht koennen die
zeilen ja als denkanstoss dienen:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
<title>checkAndFill.html</title>
<script language="JavaScript" type="text/javascript">
<!--
function checkboxClick(index)
 {var boxElement = document.forms["myForm"].elements[(index*2)];
  var inputElement = document.forms["myForm"].elements[((index*2)+1)];
  if (boxElement.checked)
  {if (document.all)
   {eval('document.all.checkbox' + index + '.className="boxChecked";');
    eval('document.all.textinput' + index + '.className="inputEnabled";');
    inputElement.disabled = false;
   }
   inputElement.focus();
  }
  if (!boxElement.checked)
  {if (document.all)
   {eval('document.all.checkbox' + index + '.className="boxUnchecked";');
    eval('document.all.textinput' + index + '.className="inputDisabled";');
    inputElement.disabled = true;
    top.focus();
   }
   if (document.layers) {inputElement.value = "";}
 } }
function inputFocus(index)
 {var boxElement = document.forms["myForm"].elements[(index*2)];
  var inputElement = document.forms["myForm"].elements[((index*2)+1)];
  if (document.layers) {if (!boxElement.checked) {boxElement.checked = true;}}
 }
function inputBlur(index)
 {var boxElement = document.forms["myForm"].elements[(index*2)];
  var inputElement = document.forms["myForm"].elements[((index*2)+1)];
  if (inputElement.value == "")
  {if (document.all)
   {eval('document.all.checkbox' + index + '.className="boxUnchecked";');
    eval('document.all.textinput' + index + '.className="inputDisabled";');
    boxElement.checked = false;
    inputElement.disabled = true;
    top.focus();
   }
   if (document.layers) {boxElement.checked = false;}
 } }

function getMyStyles()
 {var myStyles = ''+
  '<st'+'yle>\n'+
  '<!'+'--\n';
  if (document.all)
  {myStyles += ''+
   '.boxUnchecked{background-color:#f5f5f5;border-style:inset;border-width:2px;width:20px;height:20px;}\n'+
   '.boxChecked{background-color:#d3d3d3;border-style:outset;border-width:2px;width:20px;height:20px;}\n'+
   '.inputDisabled{background-color:#d3d3d3;border-style:outset;width:200px;height:20px;}\n'+
   '.inputEnabled{background-color:#f5f5f5;border-style:inset;width:200px;height:20px;color:#000000;font-family:verdana,geneva,arial,helvetica,sans-serif;font-size:10px;line-height:12px;font-weight:bold;}\n';
  }
  if (document.layers)
  {var adaptSize = (11/10);
   myStyles += ''+
   '.boxUnchecked{background-color:#d3d3d3;width:' + Math.round(20*adaptSize) + 'px;height:' + Math.round(20*adaptSize) + 'px;}\n'+
   '.inputDisabled{background-color:#f5f5f5;border-style:inset;width:200px;height:' + Math.round(20*adaptSize) + 'px;color:#000000;font-family:verdana,geneva,arial,helvetica,sans-serif;font-size:' + Math.round(10*adaptSize) + 'px;line-height:' + Math.round(12*adaptSize) + 'px;font-weight:bold;}\n';
  }
  myStyles += ''+
  '/'+'/--'+'>\n'+
  '</st'+'yle>\n';
  return myStyles;
 }
//-->
</script>
<script language="JavaScript" type="text/javascript">document.write(getMyStyles());</script>
</head>

<body>
<table cols="1" rows="1" width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
 <td align="center" valign="middle">

<form name="myForm">
 <table cols="2" rows="5" width="50" cellspacing="5" cellpadding="0" border="0">
 <tr>
  <td align="left" valign="bottom"><input type="checkbox" id="checkbox0" class="boxUnchecked" onclick="checkboxClick(0);"></td>
  <td align="left" valign="top"><input type="text" id="textinput0" class="inputDisabled" disabled onfocus="inputFocus(0);" onblur="inputBlur(0);"></td>
 </tr>
 <tr>
  <td align="left" valign="bottom"><input type="checkbox" id="checkbox1" class="boxUnchecked" onclick="checkboxClick(1);"></td>
  <td align="left" valign="top"><input type="text" id="textinput1" class="inputDisabled" disabled onfocus="inputFocus(1);" onblur="inputBlur(1);"></td>
 </tr>
 <tr>
  <td align="left" valign="bottom"><input type="checkbox" id="checkbox2" class="boxUnchecked" onclick="checkboxClick(2);"></td>
  <td align="left" valign="top"><input type="text" id="textinput2" class="inputDisabled" disabled onfocus="inputFocus(2);" onblur="inputBlur(2);"></td>
 </tr>
 <tr>
  <td align="left" valign="bottom"><input type="checkbox" id="checkbox3" class="boxUnchecked" onclick="checkboxClick(3);"></td>
  <td align="left" valign="top"><input type="text" id="textinput3" class="inputDisabled" disabled onfocus="inputFocus(3);" onblur="inputBlur(3);"></td>
 </tr>
 <tr>
  <td align="left" valign="bottom"><input type="checkbox" id="checkbox4" class="boxUnchecked" onclick="checkboxClick(4);"></td>
  <td align="left" valign="top"><input type="text" id="textinput4" class="inputDisabled" disabled onfocus="inputFocus(4);" onblur="inputBlur(4);"></td>
 </tr>
 </table>
 </form>

</td>
</tr>
</table>
</body>

</html>

viel spass - by(t)e by(t)e - peterS. - pseliger@gmx.net