How to code in fabrik+java to get element value from last row?

Hi,
I need to make button as an element in my form with action when click it:
do: select current databasejoin-dropdown element value:
{ccjom_cc_kk_karta_rejestr___ip_zamaw_zam}
select the same value like the value of this element in last row/record in the same table
table and form is '309'.

with php code i can get this element value from last row with code:
Code:
$db =& JFactory::getDBO();
$query1 = "SELECT `ccjom_cc_kk_karta_rejestr___ip_zamaw_zam ` FROM `ccjom_cc_kk_karta_rejestr` WHERE `rodzaj_karty_np_wzorzec`='2' ORDER BY `id` DESC
LIMIT 1 ";
$db->setQuery($query1);
$result1 = $db->loadResult();
return $resultt1;

I can also write java plugin code with fabrik identifier like this:
JavaScript:
var pozycja = Fabrik.getBlock('form_309').formElements.get('ccjom_cc_kk_karta_rejestr___zamow_positon_number').getValue();

var poz1 = Number(pozycja);
var dodaj = 1;
var dod1 = Number(dodaj);

var suma = poz1 + dod1;

$('ccjom_cc_kk_karta_rejestr___zamow_positon_number').value = Number(suma);

that change value in other element when click another button.

So, problem is how to get from ('list_309') value of "last"-element: (condition: WHERE `rodzaj_karty_np_wzorzec`='2')

('ccjom_cc_kk_karta_rejestr___ip_zamaw_zam')
?

i try this code, but this is not this what should be:
JavaScript:
var zamaw1 = Fabrik.getBlock('list_309').formElements.get('ccjom_cc_kk_karta_rejestr___ip_zamaw_zam').getValue();

$('ccjom_cc_kk_karta_rejestr___ip_zamaw_zam').value = 'zamaw1';
 
Last edited:
You'll need to do an AJAX call. Have a look at ./components/com_fabrik/user_ajax_example.php, which lays out how to go about doing this sort of thing.

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

Thank you.

Members online

Back
Top