Javascript second-level linkage drop-down menu

Source: Internet
Author: User
< Html >
< Head >
< Title >
Test
</ Title >
< Script Language = " Javascript " >

// VaR select1_len = Document. frm. s1.options. length;
VaR select2 =   New Array ( 4 );


For (I = 0 ; I < 4 ; I ++ )
{
Select2 [I]= NewArray ();
}
// Define basic options
Select2 [ 0 ] [ 0 ] =   New Option ( " Select " , "   " );

Select2 [ 1 ] [ 0 ] =   New Option ( " PHP " , "   " );
Select2 [ 1 ] [ 1 ] =   New Option ( " ASP " , "   " );
Select2 [ 1 ] [ 2 ] =   New Option ( " JSP " , "   " );

Select2 [ 2 ] [ 0 ] =   New Option ( " C/C ++ " , "   " );
Select2 [ 2 ] [ 1 ] =   New Option ( " Java " , "   " );
Select2 [ 2 ] [ 2 ] =   New Option ( " C # " , "   " );

Select2 [ 3 ] [ 0 ] =   New Option ( " Perl " , "   " );
Select2 [ 3 ] [ 1 ] =   New Option ( " Ruby " , "   " );
Select2 [ 3 ] [ 2 ] =   New Option ( " Python " , "   " );


Function redirec (X)
{
VaR temp = Document. frm. S2;
  For (I = 0 ; I < Select2 [X]. length; I ++ )
  {
Temp. Options [I]=NewOption (select2 [x] [I]. Text, select2 [x] [I]. value );
}
Temp. Options [ 0 ]. Selected = True ;

}
</ Script >
</ Head >
< Body >
< Form name = " FRM " >
< Select name = " S1 " Onchange = " Redirec (this. Options. selectedindex) " >
  < Option selected > Select </ Option >
  < Option value = " 1 " > Script Language </ Option >
  < Option value = " 2 " > Advanced Language </ Option >
  < Option value = " 3 " > Other languages </ Option >
</ Select >
< Select name = " S2 " >
  < Option value = " Select " Selected > Select </ Option >
</ Select >
</ Form >
</ Body >
</ Html >
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.