Results 1 to 3 of 3

Thread: JavaScript working in mozilla and not in other browsers

  1. #1
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default JavaScript working in mozilla and not in other browsers

    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>
    Last edited by hemi; 06-21-2010 at 07:27 AM.

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <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>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    hemi (06-21-2010)

  4. #3
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default

    thnks for that. It is working fine
    Last edited by hemi; 06-21-2010 at 10:05 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •