ZtVWeb.SelectCtrl=function(form,name,x,y,w,h,dataprovider,valuefield,descriptionfield){
  this.name=name
  this.form=form
  this.Ctrl=document.getElementById(name)
//  this.setCtrlPos(this.Ctrl,x,y,w,h)
  this.anchor=''
  this.topposition=y
  this.Ctrl.style.position='absolute'
  this.Ctrl.style.top=y
  this.Ctrl.style.left=x
  this.addToForm(this.form,this) //obbligatoria
  this.dataprovider=dataprovider
  this.valuefield=valuefield
  this.descriptionfield=descriptionfield

//   ZtVWeb.setCtrlStdMethods(this)

  if ( dataprovider==" "){
    var valori=this.valuefield.split(',')
    var testi=this.descriptionfield.split(',')
    var opt=new Option
    opt.text='-'
    opt.value=''
    this.Ctrl.options[0] = opt

    for(var i=0;i<testi.length;i++){
        opt=new Option
        if(Trim(valori[i])==''){
           opt.text=testi[i]
           opt.value=testi[i]
        } else {
           opt.text=testi[i]
           opt.value=valori[i]
        }
        this.Ctrl.options[this.Ctrl.options.length] = opt
    }
   }

  this.Text=function(v){
    var i
    var r
    i=this.Ctrl.selectedIndex
    return this.Ctrl.options[i].text
  }

  this.Value=function(v){
    var i
    if(v!=null){
      for (i=0;i<this.Ctrl.options.length;i++){
        if(Trim(this.Ctrl.options[i].value)==v)
          this.Ctrl.options[i].selected='selected'
      }
    }else{
      i=this.Ctrl.selectedIndex
      return this.Ctrl.options[i].value
    }
  }


  this.FillData=function(datasource){
    while(this.Ctrl.options.length>0)
      this.Ctrl.options.remove(0)
    var opt=new Option
    opt.text='-'
    opt.value=''
    this.Ctrl.options[0] = opt
    if ( datasource.nRecs>0){
      for (var i=0;i<datasource.nRecs;i++){
        opt=new Option
        opt.text=datasource.Data[i][datasource.getFldIdx(this.descriptionfield)]
        opt.value=datasource.Data[i][datasource.getFldIdx(this.valuefield)]
        this.Ctrl.options[this.Ctrl.options.length] = opt //new Option(opt, f, false, false);
      }
    }
  }

}
ZtVWeb.SelectCtrl.prototype=new ZtVWeb.StdControl


