Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

subform Manipualtion

Post Reply
at_rcc
Posts: 32
Joined: Thu Sep 02, 2010 11:19 am

subform Manipualtion

Unread post by at_rcc »

hi how do i manipulate and the element values in the subform shown below , i want to manipulate for instance all the batch id in the subform.
admin
Site Admin
Posts: 2782
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 2 times

Re: subform Manipualtion

Unread post by admin »

A subforms id is made up of three parts

eg. id="FMinvoice_item0000tri_description"

subform name FMinvoice_item row number 0000 and fieldname tri_description

if you have clicked on the row you want you can use a JavaScript function called nuGetRow()

It will give you the first two parts so that you can change the tri_description value by document.getElementById(nuGetRow()+'tri_description').value = 'whatever';

If you use nuSubformRowArray('FMinvoice_item') it will return an array of all the nuGetRows for that subform, so you can loop through them all.

http://wiki.nubuilder.com/tiki-index.ph ... #nuGetRow_

Cheers

Steven
at_rcc
Posts: 32
Joined: Thu Sep 02, 2010 11:19 am

Re: subform Manipualtion

Unread post by at_rcc »

Dear Steven i want to access the subform elements in php edit code section of the form that is when a user clicks the save button , in the form php edit code section , i want to be able to access the individual elements in the subform a
admin
Site Admin
Posts: 2782
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 2 times

Re: subform Manipualtion

Unread post by admin »

Good question,

This is the only place you cannot use hash variables, because a hash variable is essentially hardcoded into the php code just before it is run.
And you need the name of the field to change as you loop through it.

So you need to use php's $_POST array as well as the three bits to make up the field name (as explained earlier for javascript)

Code: Select all



$subformname      = "FMinvoice_item";
$rows             = $_POST["rows" . $subformname];
nuDebug($rows);  
for($i = 0 ; $i < $rows ; $i ++){

   $fieldname     = 'FMinvoice_item' . substr('000'.$i, -4)  . 'tri_amount';    //-- (three parts)

   nuDebug($_POST[$fieldname]);     //-- (this output can be found in the nuBuilder system table called zzsys_trap)
}

Steven
Post Reply