Forums

Math on hidden fields befor submit.

the_fitz 06 Oct, 2010
HI all,

Thanks in advance for all your help.

I have a couple of forms where after review (using profile plugin) the user updates the record. At this point I also have several hidden fields thai I need to do some math on to update the tables.

Can I use {field_name} to do math? Like

<?php
$new_exp_date = {old_exp_date} + 60*60*24*30*365;
$status = {old_status} + 1; // status and old status is a number
?>

or else how would I access the {old_exp_date} value and the {old_status} value to use it in a math function.

Thanks,

the_fitz
GreyHead 06 Oct, 2010
Hi the_fitz,

You can acccess the form data from the $_POST array. The Joomla! code is JRequest::getxxx() where xxx can take various values. See Joomla! docs here

In this case you might use
<?php
$old_exp_date = JRequest::getInt('old_exp_date', 0, 'post');
$new_exp_date = $old_exp_date + 60*60*24*30*365;
JRequest::setVar('old_exp_date', $old_exp_date);

$status = JRequest::getInt('old_status', 0, 'post');
$status++;
JRequest::setVar('status', $status);
?>


Bob
the_fitz 06 Oct, 2010
Bob, As usual, YOU ARE THE BEST!!!!
Thanks
The_fitz
This topic is locked and no more replies can be posted.