Set another field value from recently entered field

QuestionsSet another field value from recently entered field
Greg asked 9 years ago

Hi,

I have a time field (Start time) that when someone enters the time, I automatically want to add 1 hour to the end time (another column) and have it show in either the add view or the grid itself.

Is it possible to do this?

Thanks – Greg

3 Answers
Abu Ghufran answered 9 years ago

You can use onblur event of start time field, and invoke a JS function that will change the end time (using jquery or plain js).
Refer faq: Q) How to populate other column, based on previous columns.
http://phpgrid.org/faqs

Greg answered 9 years ago

I tried that code and put an alert(); into the function.

When I entered the cell and/or left it would never fire.

I looked at some other previous posts and the above does not seem to support inline editing correct (or has that changed)?

Do I need to do the ExcelView integration to have this work with inline?

I was trying to get it to work just by editing the record in the edit view (similar to the add view).

Thanks – Greg

Abu Ghufran answered 9 years ago

In any demo, e.g. demos/appearance/group-header.php you can try adding following line:
$col["editoptions"]["onblur"] = "$('#company').val( $('#name').val()+' company' );";

It will auto set company field onblur of name field.

$col = array();
$col["title"] = "Name";
$col["name"] = "name";
$col["editable"] = true;
$col["width"] = "80";
$col["editoptions"] = array("size"=>20);
$col["editoptions"]["onblur"] = "$('#company').val( $('#name').val()+' company' );";
$cols[] = $col;

Your Answer

19 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?