CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 "GetValue" Problem

Print topic Send  topic

Author Message
pcarr
Posted: 11/30/2003, 8:33 PM

Greetings,
Here is my code and I am not sure why it in not working.

global $main;

a = $main->ds->from_date->GetValue();
echo $a;

Value of $a on the screen is : Array

from_data is a field on my form named main.

Thanks in advance.

Paul
DaveRexel
Posted: 12/01/2003, 11:02 AM

::
Try it without the "ds->" eg

a = $main->from_date->GetValue();

Greetings
Dave

RexDesign CodeCharge Studio Tutorials
http://www.rexdesign.com/ccs/default.php
pcarr
Posted: 12/01/2003, 2:19 PM

Same result taking that out.

It is in my 'before show' section for another field on the same form. Could be that the value of "from_date" is not known at that point? It is the field before the field I am using the date to calculate with?

Thanks in advance,
Paul
DaveRexel
Posted: 12/01/2003, 3:04 PM

::
----------------
>It is in my 'before show' section for another field on the same form.
----------------

You could try addressing both components in the Records *before show* or Grids *before show row*, this also allows you to address future additional components as your project progresses.

Hope this helps,
Dave
pcarr
Posted: 12/01/2003, 4:33 PM

Well here is what I found.

If I put it in the page or grid, "Before Show" or "Before Show Row" <- on the grid. The variable is empty.

If I put it on any of the fields I get a result of "Array".

Any other thoughts?

Thanks in advance,
Paul
pcarr
Posted: 12/01/2003, 4:54 PM

I have tied it down to it has something to do with it being a "Date" type I think. I tried to show the others fields and they show just fine. Just not the date field. I am using MySQL so the date is stored in YYYY-MM-DD format and then I have it display it in MM/DD/YYYY format. Anyone know how to get a date field in custom code?

Thanks in advance,
Paul
pcarr
Posted: 12/01/2003, 5:25 PM

I found a work around for this. If someone knows how to do it better I am open for it. I put the date in a hidden field for labeled as text.

$a = substr($main->hold_date->GetValue(),0,4);
$b = date("Y");
$c = substr($main->hold_date->GetValue(),5,2);
$d = substr($main->hold_date->GetValue(),8,2);
$e = $c.$d;
$f = date("m");
$g = date("d");
$h = $f.$g;
$i = $b - $a;

if ($e > $h) {
$i = $i - 1;
}
$main->calced_age->SetValue($i);

If anyone has any other methods please let me know.

Thanks,
Paul
RonB
Posted: 12/02/2003, 3:32 PM

As you are binding a field value to a custum variable ($a) you get all the values for the field value. meaning:

if the grid has 10 rows a becomes an array of 10 x the value of the field from_date. What also can happen(depending on where you insert the before show event (grid/label) is that the value of $a get's changed ten times resulting in $a having the value of the last row's form-date value.

Maybe you can explain what it is you want to do with the $a variable after you've assigned a value to it.

RonB
pcarr
Posted: 12/02/2003, 6:28 PM

Greetings,
What I need to do is that the date of birth and calculate the persons age as of the current date. So $a I need to break apart to do the year calculation then subtract 1 if the month and day is in the future. I know I can do this by way of a SQL statemet but do not want the extra I/O to do it in custom code.

Thanks in advance,
Paul
stephenk
Posted: 12/04/2003, 1:13 AM

use CCParseDate() to create a CCS date
...->SetValue(CCParseDate("200-10-10",array("yyyy","-","mm","-","dd")));
- assigns date array to date control (Displays on web page as 2002-10-10)

use CCFormatDate() to retrieve a text version of the date
$date = CCFormatDate(...->getValue(),array("yyyy","-","mm","-","dd"));
-- gets text date from date control (print($date); will print '2002-10-10')

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.