<html>
<head>
<script language="JavaScript">
var x = 0
var style = new Array()
style[0] = "[B]"
style[1] = "[/B]"
style[2] = "[I]"
style[3] = "[/I]"
style[4] = "[U]"
style[5] = "[/U]"
style[6] = "[ALIGN=center]"
style[7] = "[/ALIGN]"
style[8] = "[ALIGN=right]"
style[9] = "[/ALIGN]"
var value = new Array()
value[0] = "B"
value[1] = "B*"
value[2] = "I"
value[3] = "I*"
value[4] = "U"
value[5] = "U*"
value[6] = ""
value[7] = "*"
value[8] = ""
value[9] = "*"
function addStyle(f,s)
{
if(x==0){
var v = document.getElementById("content").value
document.getElementById("content").value=v+style[f]
document.getElementById(f).value=value[s]
x=1
for(i=0;i<10;i++){
if(f!=i){
document.getElementById(i).disabled=true
}
}
}else{
var v = document.getElementById("content").value
document.getElementById("content").value=v+style[s]
document.getElementById(f).value=value[f]
x=0
for(i=0;i<10;i++){
if(f!=i){
document.getElementById(i).disabled=false
}
}
}
}
</script>
<title>Untitled Document</title>
<link rel="stylesheet" href="css/style.css" title="stylesheet" media="screen" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body class="content">
<table width="500" align="center">
<tr>
<th colspan="2" align="left">New subject</th>
</tr>
<tr>
<td width="32%" align="right">Subject:</td>
<td width="68%" align="left"><input type="text" name="subj"></td>
</tr>
<tr>
<td width="32%" align="right">Description:</td>
<td width="68%" align="left"><textarea name="description" cols="50"></textarea></td>
</tr>
<tr>
<td width="32%" align="right"></td>
<td width="68%" align="left">
<input type="button" onClick="addStyle('0', '1')" id="0" value="B">
<input type="button" onClick="addStyle('2', '3')" id="2" value="I">
<input type="button" onClick="addStyle('4', '5')" id="4" value="U">
<input type="button" onClick="addStyle('6', '7')" id="6" value=" ">
<input type="button" onClick="addStyle('8', '9')" id="8" value=" ">
</td>
</tr>
<tr>
<td width="32%" align="right" valign="top">Content:</td>
<td width="68%" align="left"><textarea name="content" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td width="32%" align="right"></td>
<td width="68%" align="left"><input type="button" onClick="" value="Preview"><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</body>
</html>
1.872 views
Ik heb hier het begin van een formuliertje met wat JS toepassingen. Ik wil nadat er op een button geklikt is de andere buttons disablen d.m.v een for-loopje. Het rare is dat hij alleen de eerste button disabled. Iemand enig idee waar dit aan ligt?