PHP beginner |
|
thomasje schreef: Nee ik heb nu weer getest en hij blijft de tekst weergeven.
Ik heb overigens twee textarea velden op de pagina. dan heb je 2 aparte variabelen nodig. Ik zou meteen alles wat uitgebreider maken.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>hoi</title>
<script type="text/javascript">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script type="text/javascript">
begintekst = new Array("een","twee","drie","vier","vijf","zes");
for(i=1;i<=begintekst.length;i++)
{
document.getElementById(i).value=begintekst[i]; // de fout
}
function klik(nummer)
{
if (document.getElementById(nummer).value==begintekst[nummer])
{
document.getElementById(nummer).value="";
}
}
begintekst = new Array("een","twee","drie","vier","vijf","zes"); for(i=1;i<=begintekst.length;i++) { document.getElementById(i).value=begintekst[i]; // de fout } function klik(nummer) { if (document.getElementById(nummer).value==begintekst[nummer]) { document.getElementById(nummer).value=""; } }
</script>
</head>
<body>
<textarea id="1" onclick="klik(1)"></textarea><br>
<textarea id="2" onclick="klik(2)"></textarea><br>
<textarea id="3" onclick="klik(3)"></textarea><br>
<textarea id="4" onclick="klik(4)"></textarea><br>
<textarea id="5" onclick="klik(5)"></textarea><br>
<textarea id="6" onclick="klik(6)"></textarea><br>
</body>
</html>
Edit: hmzzz... een fout... Iemand een idee?
Citaat: JavaScript - file://localhost/tmp/test1.html
Inline script thread
Error:
name: TypeError
message: Statement on line 6: Cannot convert undefined or null to Object
Backtrace:
Line 6 of inline#1 script in file://localhost/tmp/test1.html
document.getElementById(i).value=begintekst[i];
stacktrace: ... Edit:
document.getElementById(String(i)).value=begintekst[i];
document.getElementById(String(i)).value=begintekst[i];
helpt niet... |