Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Add Option Dinamix</title>
- <link type="text/css" rel="stylesheet" href="fb-1.css" />
- <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
- <script>
- $(document).ready(function() {
- var Pertama = {
- val1 : 'Pilihan Keren',
- val2 : 'Pilihan Cadas',
- val3 : 'Pilihan Ganteng',
- val4 : 'Pilihan Cool'
- };
- var Kedua = {
- val1 : 'Pilihan Jelek',
- val2 : 'Pilihan Modar',
- val3 : 'Pilihan Ancur',
- val4 : 'Pilihan Rusak'
- };
- var mySelect = $('#kedua');
- $("#pertama").change(Pertama, function(val, text) {
- $("#kedua").html("");
- if ($(this).find('option:selected').text() == 'Keren'){
- AmbilPertama()
- }else{
- AmbilKedua()
- }
- });
- function AmbilPertama(){
- $.each(Pertama, function(val, text) {
- mySelect.append(
- $('<option></option>').val(val).html(text)
- );
- });
- }
- function AmbilKedua(){
- $.each(Kedua, function(val, text) {
- mySelect.append(
- $('<option></option>').val(val).html(text)
- );
- });
- }
- });
- </script>
- </head>
- <body>
- <select id="pertama" class="ComboBox">
- <option value="0">- Pilih Data -</option>
- <option value="1">Keren</option>
- <option value="2">Jelek</option>
- </select>
- <br />
- <select id="kedua" class="ComboBox"></select>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement