PDA

View Full Version : JavaScript working in mozilla and not in other browsers



hemi
06-21-2010, 06:01 AM
Hi all,


with the bellow code iam able to run the code without any problem in mozilla but not in other .
---------------------------------------------------
<html>


<body>
<script language="javascript">
function select()
{

document.new.category.disabled=false
var1 = document.new.apptype.value

if (var1 == "Entertainment")
{
option0 = new Option(" Please Select ")
option1 = new Option("movies")
option2 = new Option("comedy")
document.new.category.options[0] = option0

document.new.category.options[1] = option1
document.new.category.options[2] = option2


}

if (var1 == "Movies")
{
option0 = new Option(" Please Select ",0)
option1 = new Option("Indra",1)
option2 = new Option("Rudhraveena",2)
document.new.category.options[0] = option0

document.new.category.options[1] = option1
document.new.category.options[2] = option2


}


// for(var i=document.new.category.options.length-1;i>=0;i--)
// document.new.category.remove(i)


}
</script>
<form method="POST" action="" enctype="multipart/form-data" name="new">
<table>
<tr>
<td width=200><b>Apptype:</b></td><td Valign="left"><select name=apptype onchange="select()"><option>--Select--</option>
<option>Entertainment</option>
<option>Movies</option></td>
</tr>
<tr>
<td width=200><b>Category:</b></td><td Valign="left"><select name="category" id="category" disabled="true" ><option>--Select--</option>
<option>Books</option></td>
</tr>

</table>


</body>
</html>

vwphillips
06-21-2010, 08:59 AM
<html>


<body>
<script language="javascript">
function select(){

document.newform.category.disabled=false
var s1=document.newform.apptype;
var var1 = s1[s1.selectedIndex].text;
var s2=document.newform.category;
s2.disabled=false
if (var1 == "Entertainment"){
s2.options[0] = new Option(" Please Select ");
s2.options[1] = new Option("movies");
s2.options[2] = new Option("comedy");
}
else if (var1 == "Movies"){
s2.options[0] = new Option(" Please Select ",0);
s2.options[1] = new Option("Indra",1);
s2.options[2] = new Option("Rudhraveena",2);
}


// for(var i=document.new.category.options.length-1;i>=0;i--)
// document.new.category.remove(i)


}
</script>
<form method="POST" action="" enctype="multipart/form-data" name="newform">
<table>
<tr>
<td width=200><b>Apptype:</b></td><td Valign="left">
<select name=apptype onchange="select()">
<option>--Select--</option>
<option>Entertainment</option>
<option>Movies</option></td>
</tr>
<tr>
<td width=200><b>Category:</b></td><td Valign="left"><select name="category" id="category" disabled="true" ><option>--Select--</option>
<option>Books</option></td>
</tr>

</table>


</body>
</html>

hemi
06-21-2010, 09:34 AM
thnks for that. It is working fine