This topic is locked
[SOLVED]

 input dissapears when checking the checkbox

1/1/2014 7:56:01 AM
PHPRunner General questions
S
shoppy author

Ok, here is something I would like.
In a table I have the invoices that have to be paid by clients.

In this table that shows the amount that has te be paid.

There is also a checkbox that shows if the invoice is paid or not.
What I like is that when the checkbox is 'checked' the amount dissapears.

The reasson is the following: when only the amount is shown that is still not paid we have a better insight off what is to be expected.
I like to have this code into an event but have no clue on how to make this.
John

C
cgphp 1/1/2014

You can format the amount using the "View as" setting http://xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm
If the the "paid" field is checked, the amount will be empty.

S
shoppy author 1/1/2014



You can format the amount using the "View as" setting http://xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm
If the the "paid" field is checked, the amount will be empty.


Hi Christian,
And how should the code look like?

Can you help?

C
cgphp 1/1/2014

Post the database names of the "Paid" and "Amount" fields.

S
shoppy author 1/1/2014



Post the database names of the "Paid" and "Amount" fields.


This is a pic of the fields:


The fieldname "Betaald" is the one with the checkbox and the fieldname "Bedrag" is the amount (like € 100,-).
Can you work with this Christian?
John

C
cgphp 1/1/2014

Set the "Bedrag" field as Custom and add the following code:

if($data['Betaald'] == 'checked')

$value = '';


I'm assuming the value for the Betaald is saved as checked in the database.

S
shoppy author 1/1/2014



Set the "Bedrag" field as Custom and add the following code:

if($data['Betaald'] == 'checked')

$value = '';


I'm assuming the value for the Betaald is saved as checked in the database.


I set de "Bedrag" field as Custom and copied the code but it doesn't doe anything when I check the "Betaald" field and save it.
Do I do something wrong?

C
cgphp 1/1/2014

What is the value of the Betaald field in the database when it is checked?

S
shoppy author 1/1/2014



What is the value of the Betaald field in the database when it is checked?


checked is 1

unchecked is 0
in the database
I changed the code in:

if($data['Betaald'] == '1')

$value = '';


and it workes!!!
Thanks very much Christian.
My last question is how to change the amount back to currency because it is now just a number.

C
cgphp 1/1/2014

My last question is how to change the amount back to currency because it is now just a number.


Not sure I understand your request.

S
shoppy author 1/1/2014

the field was set to currency so it apeared as € 2000,- (example)

now the field is changed to a code in custom and it just looks like 2000
you know what I mean?

C
cgphp 1/1/2014
if($data['Betaald'] == '1')

$value = '';

else

$value = "€ " . $value;
S
shoppy author 1/1/2014


if($data['Betaald'] == '1')

$value = '';

else

$value = "€ " . $value;



Hi Christian,
This is not realy what I ment.

I like to change the whole field into the currency format not just put a euro sign in front of it, sorry.

C
cgphp 1/1/2014

Check the PHP money_format function http://www.php.net/manual/en/function.money-format.php

S
shoppy author 1/2/2014

This is what I tried ...



if($data['Betaald'] == '1')

$value = '';

else

$value = FormatCurrency($value,2);


... but it gives an error : Fatal error: Call to undefined function FormatCurrency() in /home/vhosts/.../include/commonfunctions.php on line 705

Sergey Kornilov admin 1/2/2014

What Cristian suggested is money_format function. You are trying to do something else.

S
shoppy author 1/2/2014

Hi Sergey,
Can you help me to get what I need?

C
cgphp 1/2/2014

Check this page for an easy explanation http://www.w3schools.com/php/func_string_money_format.asp

S
shoppy author 1/3/2014

Cant get it to work like I want to.
For now I use Christian's solution

if($data['Betaald'] == '1')

$value = '';

else

$value = "€ " . $value;


Thanks for the great help.
John