Click to See Complete Forum and Search --> : Where is the error?


vinsa
04-14-2003, 06:42 AM
This is my page, but my script not work. Why?
Where is the error?




<HTML>
<HEAD>
<title>chek</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

<script language="Javascript">
function checkpwd() {

if (passwd1.value ==
passwd2.value) {
document.all.music.src='sounds/yes.au'
}
else {
document.all.music.src='sounds/no.wav'
}
}
</script>


</HEAD>
<body bgcolor=bcb49d>
<br><br><br>
<center>
<textarea name="passwd1" rows=4 cols=35 wrap=auto>
</textarea>
<br>
<textarea name="passwd2" rows=4 cols=35 wrap=auto>
</textarea>
<br>
<Button OnClick="checkpwd()" style="color:000000;background:7f7060">chek</button>
<bgsound id=music loop=1 autostart="true"> </BODY> </HTML>

pyro
04-14-2003, 06:56 AM
First of all, I'm going to assumb that the forums just broke your if statement onto two lines. Then, you use document.all. This is great for IE4, but if you are looking for more current browsers, try document.getElementById("music")

Edit:

You also referenced your textareas wrong. You need to add in a <form> tag, give it a name, and then reference them like this:

document.formname.fieldname.value