Global.helma.Html.dropDown (param, options, selectedValue, firstOption)
render a x/html drop down box

  • Parameter Object:
    the element's attributes
  • Parameter Array:
    either an array of strings, an array with several {value: v, display: d} objects, or a collection of ["value", "display"] arrays in an array
  • Parameter String:
    the currently selected value
  • Parameter String:
    the first option (without a value)
Sourcecode in /home/hannes/helma/modules/helma/Html.js:
411:   this.dropDown = function(param, options, selectedValue, firstOption) {
412:           if (!param) {
413:               res.write("[Html.dropDown: insufficient arguments]");
414:               return;
415:           }
416:           var attr = Object.clone(param);
417:           if (!attr.size)
418:               attr.size = 1;
419:           self.openTag("select", attr);
420:          res.write("\n ");
421:          if (firstOption) {
422:              self.openTag("option", {value: ""});
423:              res.write(firstOption);
424:              self.closeTag("option");
425:              res.write("\n ");
426:          }
427:          for (var i in options) {
428:              var attr = new Object();
429:              var display = "";
430:              if ((options[i] instanceof Array) && options[i].length > 0) {
431:                  // option is an array
432:                  attr.value = options[i][0];
433:                  display = options[i][1];
434:              } else if (options[i].value != null && options[i].display != null) {
435:                  // option is an object
436:                  attr.value = options[i].value;
437:                  if (options[i]["class"] != null) {
438:                     attr["class"] = options[i]["class"];
439:                  }
440:                  display = options[i].display;
441:              } else {
442:                  // assume option is a string
443:                  attr.value = i;
444:                  display = options[i];
445:              }
446:              if (isSelected(attr.value, selectedValue))
447:                  attr.selected = "selected";
448:              self.openTag("option", attr);
449:              res.write(display);
450:              self.closeTag("option");
451:              res.write("\n ");
452:          }
453:          self.closeTag("select");
454:          res.write("\n ");
455:          return;
456:      }