This topic is locked

change value of another field when one field is being entered

4/17/2007 2:11:46 AM
PHPRunner General questions
E
evan_ad2000 author

Hi,
I was wondering if this can be accomplished. I have a form for a user to log a fault report on a certain serial number. What I'm trying to do is once the serial number is entered, there is a warranty check box at the end of the page, can the value of the check box change once the serial number is entered? As in do a check on the product's serial number to check and see if it is still within warranty period. This however cannot be manually edited, can only be seen, but the value changes as the serial number changes.
Cheers,

Evan

J
Jane 4/17/2007

Evan,
you can do it using Before record added or Before record updated event on the Events tab.

Here is a sample:

if ($values["SerialNumber"]!="")

$values["Checkbox"]=1;



where SerialNumber and Checkbox are your actual field names.

N
Norian 4/20/2007

Evan,

you can do it using Before record added or Before record updated event on the Events tab.

Here is a sample:
where SerialNumber and Checkbox are your actual field names.


Hello I have a similar problem and wonder if you could expand on the code a little. I am trying to get it so when someone leaves a dealt with comment the dealt with date, and dealt with time fields will automatically be updated with the date (thinking with the now()) and time... but really dont know how to go about this. As this ticket was the only one close to what I was searching for I thought I would ask here. Many thanks.
Got it working now thanks

E
evan_ad2000 author 4/22/2007

Evan,

you can do it using Before record added or Before record updated event on the Events tab.

Here is a sample:
where SerialNumber and Checkbox are your actual field names.


Hi,

I was wondering if changing the values means the fields will be updated or the user will have to refresh or something?

Thanks,

Evan

J
Jane 4/23/2007

Evan,
this code write values to the database after you click on the Save button.
If you want to change values on the fly open generated include/commonfunction.php file and edit BuildEditControl function.

E
evan_ad2000 author 4/23/2007

Evan,

this code write values to the database after you click on the Save button.
If you want to change values on the fly open generated include/commonfunction.php file and edit BuildEditControl function.


Hi Jane,
Thanks for the tip but what does "on the fly" mean? also, what should I change or edit inside the BuildEditControl?
Thanks,

Evan

J
Jane 4/24/2007

Evan,
to change values on the fly, i.e. change values on the Add/Edit page before saving you need to add some JavaScript code to the BuildEditControl function in the include/commonfunctions.php file.

Unfortunately we don't have a ready to go solution for this.

paperhog 9/7/2007

you can do it using Before record added or Before record updated event on the Events tab.

Here is a sample:



if ($values["SerialNumber"]!="")

$values["Checkbox"]=1;



where SerialNumber and Checkbox are your actual field names.

[/quote]
Sorry to revive an old post but it is the closest to what I need

I need to check a value if yes then change a date to now()

and add one to another value

I have tried
Before Record Updated

if ($values["resend"]!= 1)

$values["intern_post_date"]= now();

$values["intern_renewed"]=+1;
Did not change the date, first time entered 1 for interned_renewed.
What am I doing wrong??

Thanks

J
Jane 9/10/2007

Lori,
try to use this code:

if ($values["resend"]!= 1)

{

$values["intern_post_date"]=now();

$values["intern_renewed"]=$values["intern_renewed"]+1;

}

paperhog 9/10/2007

Lori,

try to use this code:


The value for intern_renewed is still not adding any other feild is changing

I have reset intern_expired to 0

but it does not add 1 to intern_renewed <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=21255&image=1&table=forumreplies' class='bbcemoticon' alt='<<' />

Sergey Kornilov admin 9/10/2007

First of all you need to print $values["resend"] value on the web page.

This can help you find what is wrong:
echo $values["resend"];

paperhog 9/11/2007

First of all you need to print $values["resend"] value on the web page.

This can help you find what is wrong:
echo $values["resend"];


The Value of ["resend"]; is one but I am getting no value for ["job_renewed"]
Even if it shows as 2 it turns it back to one.

I have discovered if I have it as a read only field (as they are not to change it ) it can not read it.

If I change it to a text field it works fine!
Bug?

J
Jane 9/12/2007

Lori,
if intern_renewed field is readonly use this code:

if ($values["resend"]!= 1)

{

$values["intern_post_date"]=now();

$values["intern_renewed"]=$oldvalues["intern_renewed"]+1;

}

paperhog 9/12/2007

if ($values["resend"]!= 1)

{

$values["job_post_date"]= date("Y-m-d");

$values["job_renewed"]= $oldvalues["intern_renewed"]+1;

$values["job_okayed"]=0;

$values["job_expired"]=0;

$values["j_time"]=now();

}
Still no luck - echo $oldvalues["intern_renewed"] says 0??

All other values are what I expect. It's resetting J_okd to 0,job_expired to 0, post date to today....
Lori <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=21306&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

Alexey admin 9/13/2007

Lori,
$oldvalues["intern_renewed"] contains current intern_renewedfield value.

Not really sure what is your problem here.