Setting value of a dropdown from Javascript

Hi!

I've got a 7.js (7 is number of form) script where I want to add
a value/some values to a dropdown.

I've tried with this 3 solution but it doesn't work:

1.
form_7.formElements.get('me_save_0001_prog_educ___me_save_0001_tipo_pagamento').update('newvalue');
2. $('me_save_0001_prog_educ___me_save_0001_tipo_pagamento').update('newvalue');
3.
Fabrik.blocks['form_7'].formElements.me_save_0001_prog_educ___me_save_0001_tipo_pagamento.setValue('newvalue');

Where's the error?

Thank You.

Manuela
 
Code:
Fabrik.blocks.form_7.formElements.get('me_save_0001_prog_educ___me_save_000  1_tipo_pagamento').update('newvalue');

note 'newvalue' should be the value of the sub option and not the label e.g.

<option value="newvalue">A label</option>

will be selected

<option value="somethingelse">newvalue</option>

will NOT be selected

hth
Rob
 
Sorry. I didn't explain the problem in the right way.
I'd like to all the values that someone can choose in the drop down dinamically,
without using the cascading dropdown. Example: if I choose A in another field,
I'd like to see 1,2,3 in the dropdown; if I choose B, I'd like to see 2,4,5.

Is it possible without using the cascading dropdown plugin?

Thank You.

Manuela
 
Updating dropdown field

I tried to update the value of a dropdown field. Both of these two code examples doesn?t work:

Fabrik.blocks.form_1.formElements.get('myTable___myDropdown').update('myValue');

Fabrik.blocks.form_1.formElements.get('myTable___myDropdown_raw').update('myValue');

...where myValue is the sub option and not the label...

What I?m diong wrong?
I?m using Joomla 2.5.9 and Fabrikar 3 latest GitHub
 
Hi, does anybody got some update on this? I got the same problem, but also I want to be able to remove some of the selectable options. Thanks.
 
Using update() works for me ...

http://screencast.com/t/DlbpDflv4l

... although note that you should always use Fabrik.getBlock('form_X'), rather than trying to directly use Fabrik.blocks.form_X. This is because the name of the block will only be form_X on a new form. When editing, it'll have the rowid appended, lie form_X_Y. The getBlock() method takes this into account, and automatically gives you the block without you needing to know if it's new / edit, or know the rowid.

For adding / removing options, you'll have to use standard JavaScript ways of doing that, there's no built in Fabrik method to do it.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top