IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Utilisation d'un simple code


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Janvier 2010
    Messages
    47
    Détails du profil
    Informations forums :
    Inscription : Janvier 2010
    Messages : 47
    Par défaut Utilisation d'un simple code
    Bonjour ,

    Voila je suis completement nouveau sous Jquery et JAvascript.
    J'ai une petit application servlet/jsp très simple et je voudrais y mettre un comboBox un peu spécial,je m'explique.

    L'utilisateur pourra soit séléctionner le contenu du combo OU s'il le désire ajouter un nouvel élément directement dans le combo.
    Après plusieurs recherches j'ai trouvé sur internet des sources qui permettent de faire ça ici http://coffeescripter.com/code/edita...&color=Color+1

    Comme vous pouvez le voir,il y a 2 fichier javascript et un fichier javascript,j'ai donc tout ce qu'il me faut,le problème c est que je ne sais VRAIMENT pas comment faire pour afficher ma combo spécial dans ma jsp,c'est à dire comment faire appel au document que j'ai téléchargé et que j"ai intégré dans mon application.

    Merci de votre aide.

  2. #2
    Membre averti
    Inscrit en
    Janvier 2010
    Messages
    47
    Détails du profil
    Informations forums :
    Inscription : Janvier 2010
    Messages : 47
    Par défaut
    Je vais être un peu plus clair,voila mon fichier css :

    jquery.editable-select.css
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    input.editable-select {
      background: #FFF url(arrow-down.gif) right center no-repeat;
      padding-right: 13px;
    }
    .editable-select-options {
      position: absolute;
      display: none;
      overflow: auto;
      margin: 0;
      padding: 0;
      background: #FFF;
      border: 1px solid #CCC;
      z-index: 10;
    }
    .editable-select-iframe {
      position: absolute;
      background: #FFF;
      z-index: 9;
      display: none;
    }
      .editable-select-options ul {
        margin: 0;
        padding: 0;
        z-index: 10;
        list-style: none;
        list-style-image: none;
      }
        .editable-select-options li {
          cursor: default;
          padding: 2px;
        }
        .editable-select-options li.selected {
          background: #EAEAEA;
        }
    Voila mon premier fichier javascript jquery.editable-select.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    /**
     * Copyright (c) 2009 Anders Ekdahl (http://coffeescripter.com/)
     * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
     * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
     *
     * Version: 1.3.1
     *
     * Demo and documentation: http://coffeescripter.com/code/editable-select/
     */
    (function($) {
      var instances = [];
      $.fn.editableSelect = function(options) {
        var defaults = { bg_iframe: false,
                         onSelect: false,
                         items_then_scroll: 10,
                         case_sensitive: false
        };
        var settings = $.extend(defaults, options);
        // Only do bg_iframe for browsers that need it
        if(settings.bg_iframe && !$.browser.msie) {
          settings.bg_iframe = false;
        };
        var instance = false;
        $(this).each(function() {
          var i = instances.length;
          if(typeof $(this).data('editable-selecter') == 'undefined') {
            instances[i] = new EditableSelect(this, settings);
            $(this).data('editable-selecter', i);
          };
        });
        return $(this);
      };
      $.fn.editableSelectInstances = function() {
        var ret = [];
        $(this).each(function() {
          if(typeof $(this).data('editable-selecter') != 'undefined') {
            ret[ret.length] = instances[$(this).data('editable-selecter')];
          };
        });
        return ret;
      };
     
      var EditableSelect = function(select, settings) {
        this.init(select, settings);
      };
      EditableSelect.prototype = {
        settings: false,
        text: false,
        select: false,
        wrapper: false,
        list_item_height: 20,
        list_height: 0,
        list_is_visible: false,
        hide_on_blur_timeout: false,
        bg_iframe: false,
        current_value: '',
        init: function(select, settings) {
          this.settings = settings;
          this.select = $(select);
          this.text = $('<input type="text">');
          this.text.attr('name', this.select.attr('name'));
          this.text.data('editable-selecter', this.select.data('editable-selecter'));
          // Because we don't want the value of the select when the form
          // is submitted
          this.select.attr('disabled', 'disabled');
          var id = this.select.attr('id');
          if(!id) {
            id = 'editable-select'+ instances.length;
          };
          this.text.attr('id', id);
          this.text.attr('autocomplete', 'off');
          this.text.addClass('editable-select');
          this.select.attr('id', id +'_hidden_select');
          this.initInputEvents(this.text);
          this.duplicateOptions();
          this.positionElements();
          this.setWidths();
     
          if(this.settings.bg_iframe) {
            this.createBackgroundIframe();
          };
        },
        duplicateOptions: function() {
          var context = this;
          var wrapper = $(document.createElement('div'));
          wrapper.addClass('editable-select-options');
          var option_list = $(document.createElement('ul'));
          wrapper.append(option_list);
          var options = this.select.find('option');
          options.each(function() {
            if($(this).attr('selected')) {
              context.text.val($(this).val());
              context.current_value = $(this).val();
            };
            var li = $('<li>'+ $(this).val() +'</li>');
            context.initListItemEvents(li);
            option_list.append(li);
          });
          this.wrapper = wrapper;
          this.checkScroll();
        },
        checkScroll: function() {
          var options = this.wrapper.find('li');
          if(options.length > this.settings.items_then_scroll) {
            this.list_height = this.list_item_height * this.settings.items_then_scroll;
            this.wrapper.css('height', this.list_height +'px');
            this.wrapper.css('overflow', 'auto');
          } else {
            this.wrapper.css('height', 'auto');
            this.wrapper.css('overflow', 'visible');
          };
        },
        addOption: function(value) {
          var li = $('<li>'+ value +'</li>');
          var option = $('<option>'+ value +'</option>');
          this.select.append(option);
          this.initListItemEvents(li);
          this.wrapper.find('ul').append(li);
          this.setWidths();
          this.checkScroll();
        },
        initInputEvents: function(text) {
          var context = this;
          var timer = false;
          $(document.body).click(
            function() {
              context.clearSelectedListItem();
              context.hideList();
            }
          );
          text.focus(
            function() {
              // Can't use the blur event to hide the list, because the blur event
              // is fired in some browsers when you scroll the list
              context.showList();
              context.highlightSelected();
            }
          ).click(
            function(e) {
              e.stopPropagation();
              context.showList();
              context.highlightSelected();
            }
          ).keydown(
            // Capture key events so the user can navigate through the list
            function(e) {
              switch(e.keyCode) {
                // Down
                case 40:
                  if(!context.listIsVisible()) {
                    context.showList();
                    context.highlightSelected();
                  } else {
                    e.preventDefault();
                    context.selectNewListItem('down');
                  };
                  break;
                // Up
                case 38:
                  e.preventDefault();
                  context.selectNewListItem('up');
                  break;
                // Tab
                case 9:
                  context.pickListItem(context.selectedListItem());
                  break;
                // Esc
                case 27:
                  e.preventDefault();
                  context.hideList();
                  return false;
                  break;
                // Enter, prevent form submission
                case 13:
                  e.preventDefault();
                  context.pickListItem(context.selectedListItem());
                  return false;
              };
            }
          ).keyup(
            function(e) {
              // Prevent lots of calls if it's a fast typer
              if(timer !== false) {
                clearTimeout(timer);
                timer = false;
              };
              timer = setTimeout(
                function() {
                  // If the user types in a value, select it if it's in the list
                  if(context.text.val() != context.current_value) {
                    context.current_value = context.text.val();
                    context.highlightSelected();
                  };
                },
                200
              );
            }
          ).keypress(
            function(e) {
              if(e.keyCode == 13) {
                // Enter, prevent form submission
                e.preventDefault();
                return false;
              };
            }
          );
        },
        initListItemEvents: function(list_item) {
          var context = this;
          list_item.mouseover(
            function() {
              context.clearSelectedListItem();
              context.selectListItem(list_item);
            }
          ).mousedown(
            // Needs to be mousedown and not click, since the inputs blur events
            // fires before the list items click event
            function(e) {
              e.stopPropagation();
              context.pickListItem(context.selectedListItem());
            }
          );
        },
        selectNewListItem: function(direction) {
          var li = this.selectedListItem();
          if(!li.length) {
            li = this.selectFirstListItem();
          };
          if(direction == 'down') {
            var sib = li.next();
          } else {
            var sib = li.prev();
          };
          if(sib.length) {
            this.selectListItem(sib);
            this.scrollToListItem(sib);
            this.unselectListItem(li);
          };
        },
        selectListItem: function(list_item) {
          this.clearSelectedListItem();
          list_item.addClass('selected');
        },
        selectFirstListItem: function() {
          this.clearSelectedListItem();
          var first = this.wrapper.find('li:first');
          first.addClass('selected');
          return first;
        },
        unselectListItem: function(list_item) {
          list_item.removeClass('selected');
        },
        selectedListItem: function() {
          return this.wrapper.find('li.selected');
        },
        clearSelectedListItem: function() {
          this.wrapper.find('li.selected').removeClass('selected');
        },
        pickListItem: function(list_item) {
          if(list_item.length) {
            this.text.val(list_item.text());
            this.current_value = this.text.val();
          };
          if(typeof this.settings.onSelect == 'function') {
            this.settings.onSelect.call(this, list_item);
          };
          this.hideList();
        },
        listIsVisible: function() {
          return this.list_is_visible;
        },
        showList: function() {
          this.wrapper.show();
          this.hideOtherLists();
          this.list_is_visible = true;
          if(this.settings.bg_iframe) {
            this.bg_iframe.show();
          };
        },
        highlightSelected: function() {
          var context = this;
          var current_value = this.text.val();
          if(current_value.length < 0) {
            if(highlight_first) {
              this.selectFirstListItem();
            };
            return;
          };
          if(!context.settings.case_sensitive) {
            current_value = current_value.toLowerCase();
          };
          var best_candiate = false;
          var value_found = false;
          var list_items = this.wrapper.find('li');
          list_items.each(
            function() {
              if(!value_found) {
                var text = $(this).text();
                if(!context.settings.case_sensitive) {
                  text = text.toLowerCase();
                };
                if(text == current_value) {
                  value_found = true;
                  context.clearSelectedListItem();
                  context.selectListItem($(this));
                  context.scrollToListItem($(this));
                  return false;
                } else if(text.indexOf(current_value) === 0 && !best_candiate) {
                  // Can't do return false here, since we still need to iterate over
                  // all list items to see if there is an exact match
                  best_candiate = $(this);
                };
              };
            }
          );
          if(best_candiate && !value_found) {
            context.clearSelectedListItem();
            context.selectListItem(best_candiate);
            context.scrollToListItem(best_candiate);
          } else if(!best_candiate && !value_found) {
            this.selectFirstListItem();
          };
        },
        scrollToListItem: function(list_item) {
          if(this.list_height) {
            this.wrapper.scrollTop(list_item[0].offsetTop - (this.list_height / 2));
          };
        },
        hideList: function() {
          this.wrapper.hide();
          this.list_is_visible = false;
          if(this.settings.bg_iframe) {
            this.bg_iframe.hide();
          };
        },
        hideOtherLists: function() {
          for(var i = 0; i < instances.length; i++) {
            if(i != this.select.data('editable-selecter')) {
              instances[i].hideList();
            };
          };
        },
        positionElements: function() {
          var offset = this.select.offset();
          offset.top += this.select[0].offsetHeight;
          this.select.after(this.text);
          this.select.hide();
          this.wrapper.css({top: offset.top +'px', left: offset.left +'px'});
          $(document.body).append(this.wrapper);
          // Need to do this in order to get the list item height
          this.wrapper.css('visibility', 'hidden');
          this.wrapper.show();
          this.list_item_height = this.wrapper.find('li')[0].offsetHeight;
          this.wrapper.css('visibility', 'visible');
          this.wrapper.hide();
        },
        setWidths: function() {
          // The text input has a right margin because of the background arrow image
          // so we need to remove that from the width
          var width = this.select.width() + 2;
          var padding_right = parseInt(this.text.css('padding-right').replace(/px/, ''), 10);
          this.text.width(width - padding_right);
          this.wrapper.width(width + 2);
          if(this.bg_iframe) {
            this.bg_iframe.width(width + 4);
          };
        },
        createBackgroundIframe: function() {
          var bg_iframe = $('<iframe frameborder="0" class="editable-select-iframe" src="about:blank;"></iframe>');
          $(document.body).append(bg_iframe);
          bg_iframe.width(this.select.width() + 2);
          bg_iframe.height(this.wrapper.height());
          bg_iframe.css({top: this.wrapper.css('top'), left: this.wrapper.css('left')});
          this.bg_iframe = bg_iframe;
        }
      };
    })(jQuery);
    et mon dernier fichier javascript jquery.editable-select.pack.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    /**
     * Copyright (c) 2009 Anders Ekdahl (http://coffeescripter.com/)
     * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
     * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
     *
     * Version: 1.3.1
     *
     * Demo and documentation: http://coffeescripter.com/code/editable-select/
     */
    eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){5 g=[];$.1e.1E=3(a){5 b={l:8,Y:8,Z:10,11:8};5 c=$.1F(b,a);6(c.l&&!$.1G.1H){c.l=8};5 d=8;$(1).M(3(){5 i=g.r;6(12 $(1).v(\'m-w\')==\'1f\'){g[i]=1I h(1,c);$(1).v(\'m-w\',i)}});p $(1)};$.1e.1J=3(){5 a=[];$(1).M(3(){6(12 $(1).v(\'m-w\')!=\'1f\'){a[a.r]=g[$(1).v(\'m-w\')]}});p a};5 h=3(a,b){1.1g(a,b)};h.1K={n:8,j:8,k:8,7:8,14:20,B:0,N:8,1L:8,l:8,C:\'\',1g:3(a,b){1.n=b;1.k=$(a);1.j=$(\'<1M 1N="j">\');1.j.t(\'1h\',1.k.t(\'1h\'));1.j.v(\'m-w\',1.k.v(\'m-w\'));1.k.t(\'1i\',\'1i\');5 c=1.k.t(\'15\');6(!c){c=\'m-k\'+g.r};1.j.t(\'15\',c);1.j.t(\'1O\',\'1P\');1.j.O(\'m-k\');1.k.t(\'15\',c+\'1Q\');1.1j(1.j);1.1k();1.1l();1.16();6(1.n.l){1.1m()}},1k:3(){5 b=1;5 c=$(D.1n(\'1R\'));c.O(\'m-k-1S\');5 d=$(D.1n(\'1o\'));c.z(d);5 e=1.k.u(\'17\');e.M(3(){6($(1).t(\'x\')){b.j.s($(1).s());b.C=$(1).s()};5 a=$(\'<q>\'+$(1).s()+\'</q>\');b.18(a);d.z(a)});1.7=c;1.19()},19:3(){5 a=1.7.u(\'q\');6(a.r>1.n.Z){1.B=1.14*1.n.Z;1.7.o(\'P\',1.B+\'Q\');1.7.o(\'1p\',\'1q\')}E{1.7.o(\'P\',\'1q\');1.7.o(\'1p\',\'1r\')}},1T:3(a){5 b=$(\'<q>\'+a+\'</q>\');5 c=$(\'<17>\'+a+\'</17>\');1.k.z(c);1.18(b);1.7.u(\'1o\').z(b);1.16();1.19()},1j:3(a){5 b=1;5 c=8;$(D.1a).1s(3(){b.y();b.F()});a.1U(3(){b.R();b.G()}).1s(3(e){e.1t();b.R();b.G()}).1V(3(e){1W(e.1u){H 1X:6(!b.1v()){b.R();b.G()}E{e.I();b.1b(\'1w\')};S;H 1Y:e.I();b.1b(\'1Z\');S;H 9:b.T(b.J());S;H 27:e.I();b.F();p 8;S;H 13:e.I();b.T(b.J());p 8}}).21(3(e){6(c!==8){22(c);c=8};c=23(3(){6(b.j.s()!=b.C){b.C=b.j.s();b.G()}},24)}).25(3(e){6(e.1u==13){e.I();p 8}})},18:3(a){5 b=1;a.26(3(){b.y();b.K(a)}).28(3(e){e.1t();b.T(b.J())})},1b:3(a){5 b=1.J();6(!b.r){b=1.U()};6(a==\'1w\'){5 c=b.29()}E{5 c=b.2a()};6(c.r){1.K(c);1.V(c);1.1x(b)}},K:3(a){1.y();a.O(\'x\')},U:3(){1.y();5 a=1.7.u(\'q:2b\');a.O(\'x\');p a},1x:3(a){a.1y(\'x\')},J:3(){p 1.7.u(\'q.x\')},y:3(){1.7.u(\'q.x\').1y(\'x\')},T:3(a){6(a.r){1.j.s(a.j());1.C=1.j.s()};6(12 1.n.Y==\'3\'){1.n.Y.2c(1,a)};1.F()},1v:3(){p 1.N},R:3(){1.7.1c();1.1z();1.N=1A;6(1.n.l){1.l.1c()}},G:3(){5 b=1;5 c=1.j.s();6(c.r<0){6(2d){1.U()};p};6(!b.n.11){c=c.1B()};5 d=8;5 e=8;5 f=1.7.u(\'q\');f.M(3(){6(!e){5 a=$(1).j();6(!b.n.11){a=a.1B()};6(a==c){e=1A;b.y();b.K($(1));b.V($(1));p 8}E 6(a.2e(c)===0&&!d){d=$(1)}}});6(d&&!e){b.y();b.K(d);b.V(d)}E 6(!d&&!e){1.U()}},V:3(a){6(1.B){1.7.2f(a[0].2g-(1.B/2))}},F:3(){1.7.W();1.N=8;6(1.n.l){1.l.W()}},1z:3(){2h(5 i=0;i<g.r;i++){6(i!=1.k.v(\'m-w\')){g[i].F()}}},1l:3(){5 a=1.k.2i();a.L+=1.k[0].1C;1.k.2j(1.j);1.k.W();1.7.o({L:a.L+\'Q\',X:a.X+\'Q\'});$(D.1a).z(1.7);1.7.o(\'1D\',\'2k\');1.7.1c();1.14=1.7.u(\'q\')[0].1C;1.7.o(\'1D\',\'1r\');1.7.W()},16:3(){5 a=1.k.A()+2;5 b=2l(1.j.o(\'2m-2n\').2o(/Q/,\'\'),10);1.j.A(a-b);1.7.A(a+2);6(1.l){1.l.A(a+4)}},1m:3(){5 a=$(\'<1d 2p="0" 2q="m-k-1d" 2r="2s:2t;"></1d>\');$(D.1a).z(a);a.A(1.k.A()+2);a.P(1.7.P());a.o({L:1.7.o(\'L\'),X:1.7.o(\'X\')});1.l=a}}})(2u);',62,155,'|this||function||var|if|wrapper|false|||||||||||text|select|bg_iframe|editable|settings|css|return|li|length|val|attr|find|data|selecter|selected|clearSelectedListItem|append|width|list_height|current_value|document|else|hideList|highlightSelected|case|preventDefault|selectedListItem|selectListItem|top|each|list_is_visible|addClass|height|px|showList|break|pickListItem|selectFirstListItem|scrollToListItem|hide|left|onSelect|items_then_scroll||case_sensitive|typeof||list_item_height|id|setWidths|option|initListItemEvents|checkScroll|body|selectNewListItem|show|iframe|fn|undefined|init|name|disabled|initInputEvents|duplicateOptions|positionElements|createBackgroundIframe|createElement|ul|overflow|auto|visible|click|stopPropagation|keyCode|listIsVisible|down|unselectListItem|removeClass|hideOtherLists|true|toLowerCase|offsetHeight|visibility|editableSelect|extend|browser|msie|new|editableSelectInstances|prototype|hide_on_blur_timeout|input|type|autocomplete|off|_hidden_select|div|options|addOption|focus|keydown|switch|40|38|up||keyup|clearTimeout|setTimeout|200|keypress|mouseover||mousedown|next|prev|first|call|highlight_first|indexOf|scrollTop|offsetTop|for|offset|after|hidden|parseInt|padding|right|replace|frameborder|class|src|about|blank|jQuery'.split('|'),0,{}))
    voila ouf
    Tous ce que je veux ,c est afficher dans ma jsp,cette fameuse combobox magique...comment faire pour l'afficher!!

    Merci pour votre aide.

  3. #3
    Membre Expert
    Avatar de Loceka
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    2 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 2 276
    Par défaut
    T'as un exemple de comment faire sur le site où t'as eu le code :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    $(function() {
      $('.editable-select').editableSelect(
        {
          bg_iframe: true,
          onSelect: function(list_item) {
            alert('List item text: '+ list_item.text());
            // 'this' is a reference to the instance of EditableSelect
            // object, so you have full access to everything there
            alert('Input value: '+ this.text.val());
          },
          case_sensitive: false, // If set to true, the user has to type in an exact
                                 // match for the item to get highlighted
          items_then_scroll: 10 // If there are more than 10 items, display a scrollbar
        }
      );
      var select = $('.editable-select:first');
      var instances = select.editableSelectInstances();
      instances[0].addOption('Germany, value added programmatically');
    });

  4. #4
    Membre averti
    Inscrit en
    Janvier 2010
    Messages
    47
    Détails du profil
    Informations forums :
    Inscription : Janvier 2010
    Messages : 47
    Par défaut
    Oui Loceka,mais il est ou le code html pour appeler le comboBox?
    Je ne vois pas (je suis hyper débutant) comment faire le lien avec le code html!!!

    Voila ce que j'ai mis dans ma jsp mais ça ne donne rien !!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    	pageEncoding="ISO-8859-1"%>
     
    <!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>TEST</title>
    <link href="../css/default_css.css" rel="stylesheet" type="text/css" />
    <script src="../javascript/jquery.editable-select.js"></script>
    <link href="../css/jquery.editable-select.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    $(function() {
      $('.editable-select').editableSelect(
        {
          bg_iframe: true,
          onSelect: function(list_item) {
            alert('List item text: '+ list_item.text());
            // 'this' is a reference to the instance of EditableSelect
            // object, so you have full access to everything there
            alert('Input value: '+ this.text.val());
          },
          case_sensitive: false, // If set to true, the user has to type in an exact
                                 // match for the item to get highlighted
          items_then_scroll: 10 // If there are more than 10 items, display a scrollbar
        }
      );
      var select = $('.editable-select:first');
      var instances = select.editableSelectInstances();
      instances[0].addOption('Germany, value added programmatically');
    });
    </script>
    </head>
    <select id="editable-select" name="editable-select">
     
            <option value="1">Notification</option>
     
            <option value="2">Avertissement</option>
     
            <option value="3">Priorité moyenne</option>
            <option value="4">Priorité élevée</option>
     
        </select>

    MErci

Discussions similaires

  1. [VS2005] Comment utiliser la documentation du code en C++ ?
    Par StormimOn dans le forum Visual Studio
    Réponses: 8
    Dernier message: 16/09/2006, 16h46
  2. Réponses: 2
    Dernier message: 22/08/2006, 11h28
  3. Réponses: 2
    Dernier message: 01/05/2006, 19h15
  4. decortiquer un simple code
    Par splinternabs dans le forum C++
    Réponses: 3
    Dernier message: 23/04/2006, 06h52
  5. Utilisation de 'cout' et code portable ??
    Par LaVaZza dans le forum SL & STL
    Réponses: 3
    Dernier message: 05/12/2005, 19h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo