Php question (solved)

Status
Not open for further replies.

amras

New Member
Hi Fabrik developers

I have a problem with geting a result from the form i created.

I have 3 colums form: 2 text feild with the checkbox numbers check and 1 hidden also with checkbox Eval and numbers check.

I the hidden textfield i want to show the result of the 2 others textfields by mutilpy them in the table.

In the hiddden textfield in the default value i have this php code
Code:
 print($row_jos_fabrik_formdata_18['telt'] * $row_jos_fabrik_formdata_18['camping']);
but i dosent work?

I have tryed this php code to
Code:
return ($row_jos_fabrik_formdata_18['telt'] * $row_jos_fabrik_formdata_18['camping']);

What shuold i do to get the result? i have uploade the package to
 

Attachments

  • fabrik_package-pac.tgz
    4.2 KB · Views: 271
Re: Php question

you need to do this type of calculation in javascript rather than php. As the calculation needs to be made when the form is submitted and/or when the fields values are changed.

Presuming your hidden element is called "result" try adding this "onchange" javascript event to both the elements "telt" and "camping"

Code:
$('jos_fabrik_formdata_18___result').value = $('jos_fabrik_formdata_18___telt').value * $('jos_fabrik_formdata_18___camping').value


(All the strings encased in $('...') refer the the fields id value, when written out to the form)
 
Re: Php question

Ok the two textfield elements with the id 'telt' and 'camping' i have made a javascript element and inserted your code
Code:
$('jos_fabrik_formdata_18___vis').value = $('jos_fabrik_formdata_18___telt').value * $('jos_fabrik_formdata_18___camping').value
into the javascipt field with a javascript action "onchange".

In the hidden textfiled i have tryed to put the code
Code:
return ($row_jos_fabrik_formdata_18['telt'] * $row_jos_fabrik_formdata_18['camping']);
in the default field or leave it empty.

Nothing of above is showing the the result in the hidden textfield iam a doing it wrong or?
 

Attachments

  • fabrik_package-result.tgz
    4.3 KB · Views: 272
Re: Php question

You don't need to put anything into the eval section of the element, in fact turn off the eval checkbox. The Javascript will update the form dynamically and add that value.

To see that it is you can use the Firefox extension Firebug, which will allow you to dynamically inspect your elements.

Andre
 
Re: Php question

Solved :)

Thank to both for the help.

The code that Rob Clayburn was the right one for the job only mistake was the name of the id was wrong so i used firefox webdeveloper to find out the right name of the id for teh textfield.

I thought that tht name was Jos_fabrik_formdata_18 + the id name of the element.

But it was missing mf_el in the start so the right code would be
Code:
$('mf_el_jos_fabrik_formdata_18___vis').value = $('mf_el_jos_fabrik_formdata_18___telt').value * $('mf_el_jos_fabrik_formdata_18___camping').value
.

But thanks again.
 
Re: Php question

Yes i hopes other can use it ass well , very soon we have enogth answer to make a search
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top