push value to array (javascript)

keith21

Member
Hi
can anyone help me with this code below. I need to push data from original to amended field.
Code:
var originaldata = Fabrik.getBlock('form_79').elements.get('pim_staff___ENID_Staff_Original');
var amendeddata = Fabrik.getBlock('form_79').elements.get('pim_staff___ENID_Staff_Amended');
var original = originaldata.get('value');
var amended = amendeddata.get('value');
if (amended === '') {document.getElementById("pim_staff___ENID_Staff_Amended").values.push('original'))}
 
Yeah, that's not even close. :)

Exact code needed depends on what element types they are.

Can you point me at the page?

-- hugh
 
OK, so what are you actually trying to do? Append the value of 'original' to 'ammended'? What should trigger it? A change to original?

-- hugh
 
OK, what I want the edit button to do is simply if the user clicks on the button is coz they are not happy with the current details held for them. The details are sent from original to amended feild for user to change. If the edit button is not hit coz details are correct then it is automatically moved into the amended feild, to be saved.
 
Not sure what you mean by "if the button is not hit". How can a non action trigger anything? Or do you mean on save, if the amended field is empty, copy the original in to it?

Sent from my HTC One using Tapatalk
 
sorry forgive me for that explantion. Yes on save if amended feild is empty, copy from original.

Thanks
 
You'd probably be better off doing that bit with a php submission plugin.

Sent from my HTC One using Tapatalk
 
So on form submission I could do something like this:
Code:
$original = $formModel->getElementData('pim_staff___ENID_Staff_Original');
$amended = $formModel->getElementData('pim_staff___ENID_Staff_Amended');

if ($amended === '')
{
  $formModel->updateFormData('pim_staff___ENID_Staff_Amended', 'pim_staff___ENID_Staff_Original', true);
}

please forgive me if the code is incorrect as I am no coder, but do try :)

Thanks

Keith
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top