Page 1 of 1

subform Manipualtion

Posted: Wed Jun 15, 2011 7:40 am
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.

Re: subform Manipualtion

Posted: Wed Jun 15, 2011 8:42 am
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

Re: subform Manipualtion

Posted: Wed Jun 15, 2011 9:07 am
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

Re: subform Manipualtion

Posted: Thu Jun 16, 2011 3:54 am
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