Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Adding Timestamp Into The Form Data By Using Javascript Rate Topic   - - - - -

 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 297 posts

Posted 01 June 2019 - 09:28 AM #1

I am trying to develop an addon.

 

part of php:

 $objects = array_values(array_map(function ($category) use ($view, $company_id) {

                $view->assign('category', $category);
						
		return array(
                    'id' => $category['id'],
                    'text' => $category['name'],
                );
			

        }, $categories));
    }
        Tygh::$app['ajax']->assign('objects', $objects);

part of TPL file:

<form action="{""|fn_url}" method="post" class="form-vertical" name="paket_form" enctype="multipart/form-data">
   <select
    class="cm-object-selector"
    name="category[ids]"
	data-ca-load-via-ajax="{"true"}"
	data-ca-data-url="{"cce_paket_yonetimi.get_cat_list"|fn_url nofilter}"
    >
    </select>


{include file="buttons/save_cancel.tpl" but_text=__("save") but_meta="cm-product-save-buttons" but_role="submit-link" but_name="dispatch[cce_paket_yonetimi.update]" but_target_form="paket_form" save=$id}

</form>

I import some values trough array map in php  and show them in ajax select option in form. Then I post selected values.

 

I want to add an extra field that adds currently timestamp when a value selected, at the time when mouse clicked/selected a value and post that timestampo field with selected ids in array.

 

Like this:

Array
(
    [category] => Array
        (
            [id] => 13,
            [timestamp_added] => 1559380913
        )

) 

I am not mentioning the timestamp that values will be posted into the database, I mean timestamp that items will be selected. becuse each tiem is going to be selected in different time when by clicking mouse. I need to add its timestamp when selected for each item added.

 

 

How can I do this? I think I need to add timestamo using JS. 

 

I will be very glad if you help by writing example codes or guide with your any idea.



 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 297 posts

Posted 11 June 2019 - 09:26 AM #2

Anyone who can help? :)