javascript error: object expected
Posted: Wed Sep 23, 2009 11:57 pm
Hello friends
i am using this javascript....please help me to find the error
<form action="" id="form2" method="post" name="form1" class="style1">
<script language="javascript">
function addOption(selectList,optionText,optionValue)
{
var newOption = document.createElement('OPTION');
newOption.text = optionText;
newOption.value = optionValue;
selectList.options.add(newOption);
}
function changeList(list1,list2) {
list2.length = 0;
if(list1.options[list1.selectedIndex].value == 1)
{
alert('i am in 2.');
addOption(list2,"LECT","LECT");
addOption(list2,"ASST","ASST");
addOption(list2,"PROF","PROF");
}
else if(list1.options[list1.selectedIndex].value == 2)
{
alert('i am in 3.');
addOption(list2,"PA","PA");
addOption(list2,"JAAT","JAAT");
addOption(list2,"JOAT","JOAT");
}
else if(list1.options[list1.selectedIndex].value == 3)
{
alert('i am in 4.');
addOption(list2,"SAMPLE","SAMPLE");
}
</script>
<br><br>
<label>3. Employee Type</label>
<select name="emptyp" onChange="changeList(this,this.form1.desg)">
<option value="2">2 (Teaching faculty)</option>
<option value="3">3 (Supporting staff)</option>
<option value="4">4 (Helping staff)</option>
</select> <br> <br>
<label >9. Designation</label>
<select name="desg"> </select><br><br>
in my javascript its giving object expected on line
addOption(list2,"JAAT","JAAT");
i am using this javascript....please help me to find the error
<form action="" id="form2" method="post" name="form1" class="style1">
<script language="javascript">
function addOption(selectList,optionText,optionValue)
{
var newOption = document.createElement('OPTION');
newOption.text = optionText;
newOption.value = optionValue;
selectList.options.add(newOption);
}
function changeList(list1,list2) {
list2.length = 0;
if(list1.options[list1.selectedIndex].value == 1)
{
alert('i am in 2.');
addOption(list2,"LECT","LECT");
addOption(list2,"ASST","ASST");
addOption(list2,"PROF","PROF");
}
else if(list1.options[list1.selectedIndex].value == 2)
{
alert('i am in 3.');
addOption(list2,"PA","PA");
addOption(list2,"JAAT","JAAT");
addOption(list2,"JOAT","JOAT");
}
else if(list1.options[list1.selectedIndex].value == 3)
{
alert('i am in 4.');
addOption(list2,"SAMPLE","SAMPLE");
}
</script>
<br><br>
<label>3. Employee Type</label>
<select name="emptyp" onChange="changeList(this,this.form1.desg)">
<option value="2">2 (Teaching faculty)</option>
<option value="3">3 (Supporting staff)</option>
<option value="4">4 (Helping staff)</option>
</select> <br> <br>
<label >9. Designation</label>
<select name="desg"> </select><br><br>
in my javascript its giving object expected on line
addOption(list2,"JAAT","JAAT");