hi
i can't work out why my function which checks to see if the user has selected an item from the drop down box doesn't work...
any ideas?
thanks
i can't work out why my function which checks to see if the user has selected an item from the drop down box doesn't work...
any ideas?
thanks
Code:
<html>
<HEAD>
<script language='JavaScript'>
<!--
function changeFile(the_file)
{ document.getElementById('thePlayer').FileName = the_file; }
//-->
</script>
<Script Language="JavaScript">
<!--
function testChar() {
var num = " .-?!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (var intLoop = 0; intLoop < the_form.sound_answer.value.length; intLoop++) {
if (-1 == num.indexOf(the_form.sound_answer.value.charAt(intLoop))) {
alert ("You have used illegal characters in the \"Sound Answer\" field \nOnly a-z (upper or lower case), space, \".\", \"?\", \"!\", \"-\" are permitted.");
return false;
}
}
return true;
}
[b]function testDrop()
{
if ((document.forms[0].elements[0].value == "Select a Sound"))
{
alert("You must select a sound.");
return false;
}
return true;
}[/b]
function testEmpty()
{
if (the_form.sound_answer.value == "")
{
alert("Please complete all fields");
return false;
}
return true;
}
function validate()
{
var theResult = true;
theResult = testChar() && testDrop() && testEmpty();
return theResult;
}
//-->
</script>
</HEAD>
<body><BR>
<h2>Playing The Object</h2>
<form action ='[URL unfurl="true"]http://localhost:8080/myApp/servlet/FinishReg?uID=389&picID=7'[/URL] METHOD='POST' name='the_form' onSubmit="return validate()">
[b]<select name='choose_file'
onChange='changeFile(this.options[selectedIndex].value);'>
<option value='' selected>Select a Sound</option>
<option value='c:\loop1.wav'>1</option>
<option value='c:\loop2.wav'>2</option>
<option value=''>6</option>
</select>[/b]
<BR><BR><object height='8%' width='30%' id='thePlayer' classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95'>
<param name='AutoStart' value='1' />
<param name='FileName' value ='' />
</object> <BR>Please enter word or phrase associated with your sound.<BR>
<INPUT TYPE='TEXT' NAME='sound_answer'><BR><BR>
<INPUT TYPE='submit' NAME = 'submit' VALUE='submit' ></form>
<BR><BR>
</body>
<BR><BR>
</html>