# Solution Model: 2 comboboxes, different behavior

**URL:** https://forum.servoy.com/t/solution-model-2-comboboxes-different-behavior/17176
**Category:** Classic Servoy
**Created:** [April 13, 2013, 8:11am UTC](https://forum.servoy.com/t/solution-model-2-comboboxes-different-behavior/17176 "2013-04-13T08:11:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)
#### Post date: [April 13, 2013, 8:11am UTC](https://forum.servoy.com/t/solution-model-2-comboboxes-different-behavior/17176/1 "2013-04-13T08:11:53Z")

</div>

There is something I don’t understand, but I am quite sure there is some oversight by me.

In a solution model form I have two comboboxes with identical code.  
**1st combobox (repCombo)**

```auto
var vl_repIns = solutionModel.newValueList('vl_repIns' + application.getTimeStamp(), JSValueList.CUSTOM_VALUES);
	vl_repIns.customValues = 'Replace|REPLACE\nInsert|INSERT';
	var repIns = frmCsv.newVariable('repIns',JSVariable.TEXT);
	
	var repCombo = frmCsv.newField(repIns,JSField.COMBOBOX,450,300,220,20);
	repCombo.valuelist = vl_repIns;
	repCombo.transparent = true;
	repCombo.editable = false;

```

**2nd combobox (testCombo)**

```auto
var vltest1 = solutionModel.newValueList('testcombovl' + application.getTimeStamp(),JSValueList.CUSTOM_VALUES);
	vltest1.customValues = 'Do Not Import|@dummy\nImport|import'
	var testVar = frmCsv.newVariable('test_csv',JSVariable.TEXT);
		
	var testCombo = frmCsv.newField(testVar,JSField.COMBOBOX,450,50,220,20);
	testCombo.valuelist = vltest1;
	testCombo.transparent = true;
	testCombo.editable = false;

```

I want to display an initial value when the form is shown. This is the method:  
var onShowFrmCsv = frmCsv.newMethod(“function onShow(firstShow,event) { repIns = ‘REPLACE’; testVar = ‘@dummy’; }”);

Apparently both comboboxes should display a value (‘Replace’ and ‘Do Not Import’ respectively). But only one is shown (Replace), the other is blank. Any idea?

---

<div class="post-metadata">

### Author: ![sovanm](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@sovanm](https://forum.servoy.com/u/sovanm)
#### Post date: [April 13, 2013, 4:05pm UTC](https://forum.servoy.com/t/solution-model-2-comboboxes-different-behavior/17176/2 "2013-04-13T16:05:56Z")

</div>

Hi,

Actually the problem is you have assigned the value to be shown first to jsVariable (testVar) in onShow method in place of the variable name(test\_csv). Please change it to ‘test\_csv’ and it is working.

Hope this will solve your problem.

Thanks  
Sovan

---

<div class="post-metadata">

### Author: ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)
#### Post date: [April 14, 2013, 8:15am UTC](https://forum.servoy.com/t/solution-model-2-comboboxes-different-behavior/17176/3 "2013-04-14T08:15:12Z")

</div>

Hi Sovan,  
thank you for your help. I played with different combinations of variable, variable name and data provider and I found that normally the data provider can be either the variable itself or the variable name.

**In this scenario** `var test_Var = frmCsv.newVariable('testVar',JSVariable.TEXT);` the data provider can be both test\_Var (the variable) or ‘testVar’ (the name) and both these statements seem to work `var testCombo = frmCsv.newField(test_Var,JSField.COMBOBOX,50,50,220,20);` or ```  
var testCombo = frmCsv.newField(‘testVar’,JSField.COMBOBOX,50,50,220,20);

```auto
BUT, using variable **testVar** instead of **test_Var** (without the underscore) the method doesn't work any more either with the variable name as data provider 

```

var testVar = frmCsv.newVariable(‘test\_Var’,JSVariable.TEXT);  
var testCombo = frmCsv.newField(‘test\_Var’,JSField.COMBOBOX,50,50,220,20);

````auto

or with the variable itself ```
var testCombo = frmCsv.newField(testVar,JSField.COMBOBOX,50,50,220,20);

````

I don’t understand why. A naming problem? Why?

---

<div class="post-metadata">

### Author: ![sovanm](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@sovanm](https://forum.servoy.com/u/sovanm)
#### Post date: [June 11, 2013, 8:44am UTC](https://forum.servoy.com/t/solution-model-2-comboboxes-different-behavior/17176/4 "2013-06-11T08:44:48Z")

</div>

Hi,

```auto
var testVar = frmCsv.newVariable('test_csv',JSVariable.TEXT);
var onShowFrmCsv = frmCsv.newMethod("function onShow(firstShow,event) { repIns = 'REPLACE'; testVar = '@dummy'; }");

```

Here you have created a variable with name ‘test\_csv’ but in onShow method you are assigning the default value(@dummy) to ‘testVar’ which do not exist.

which should be:

```auto
var onShowFrmCsv = frmCsv.newMethod("function onShow(firstShow,event) { repIns = 'REPLACE'; test_csv = '@dummy'; }");

```

Thanks  
Sovan Misra  
[http://www.mindfiresolutions.com](http://www.mindfiresolutions.com)
