Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    verifica codice per popolare select

    Ciao ragazzi mi date una mano non riesco a capire perchè non funziona questo script.

    <script language="JavaScript">

    var arItems = new Array()

    arItems = [

    [AUTO, 10, 'BMW'],
    [AUTO, 10, 'ALFA'],
    [AUTO, 10, 'fiat'],
    [AUTO, 10, 'AUDI'],
    [AUTO, 10, 'renault'],
    [AUTO, 10, 'seat']
    ]

    function fillItems( intStart ) {

    var fTypes = document.form1.types
    var fItems = document.form1.items
    var a = arItems
    var b, c, d, intItem, intType

    if ( intStart > 0 ) {
    for ( b = 0; b < a.length; b++ ) {
    if ( a[b][1] == intStart ) {
    intType = a[b][0];
    }
    }

    for ( c = 0; c < fTypes.length; c++ ) {
    if ( fTypes.options[ c ].value == intType ) {
    fTypes.selectedIndex = c;
    }
    }
    }

    if ( intType == null ) {
    intType = fTypes.options[ fTypes.selectedIndex ].value
    }

    fItems.options.length = 0;

    for ( d = 0; d < a.length; d++ ) {
    if ( a[d][0] == intType ) {
    fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] ); // no line-break here
    }

    if ( a[d][1] == intStart ) {
    fItems.selectedIndex = fItems.options.length - 1;
    }
    }
    }

    </script>

    <form name="form1">
    <select name="types" onChange="fillItems(0)">
    <option value="#" selected="selected">Please select</option>
    <option value="AUTO">AUTO</option>
    <option value="MOTO">MOTO</option>

    <option value="CAMPER">CAMPER</option>
    <option value="ciao">ciao</option>
    </select>

    <select name="items"></select>
    </form>

    Grazie mille
    Andrea
    AweDesign "power & Creation"
    Tecnical supp:info@awedesign.net
    sito:http://www.awedesign.net

  2. #2
    codice:
    [AUTO, 10, 'BMW']

    credo che AUTO debba essere una stringa, quindi:

    codice:
    ['AUTO', 10, 'BMW']

  3. #3
    Grazie mille ora funziona !!
    AweDesign "power & Creation"
    Tecnical supp:info@awedesign.net
    sito:http://www.awedesign.net

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.