Page 1 of 1

Message box after insert

Posted: 2020-04-03 12:23
by imike
Hello,
After adding the record, the message box (alert) does not appear. How to solve this problem?

Code: Select all

	function ttr_warehouse_ttr_after_insert($data, $memberInfo, &$args) {

		$quantity = sqlValue("select `ttr_warehouse_ttr`.`quantity` from `ttr_warehouse_ttr` where id='{$data['id']}'");
		if ($data['add_ttr'] == !null) {
		$quantity = $quantity + $data['add_ttr'];
		sql("update `ttr_warehouse_ttr` set `ttr_warehouse_ttr`.`quantity` = '{$quantity}' where id='{$data['id']}'", $eo);
		sql("update `ttr_warehouse_ttr` set `ttr_warehouse_ttr`.`add_ttr` = NULL where id='{$data['id']}'", $eo);

?>	
		<script type="text/javascript">
			$j(document).ready(function(){
			alert('Added: <?php $quantity ?>');
			});
		</script>
<?php	
		}	

		return TRUE;
	}

Re: Message box after insert

Posted: 2020-04-03 21:14
by pbottcher
Hi,

you cannot use the html (<script>...) in the hook file like you do. The hook is called as a function and you cannot modify the DOM via the _before / _after functions.

Re: Message box after insert

Posted: 2020-04-06 06:14
by imike
Heloo pböttcher,

Thank you for your answer. So how can I do it? Using the table_name-dv.js file?

Re: Message box after insert

Posted: 2020-04-06 19:52
by pbottcher
Hi,

have a look into this post.

viewtopic.php?f=7&t=1740&p=10871#p10877

hope that helps

Re: Message box after insert

Posted: 2020-04-07 13:03
by imike
Thank you for your help. I will try to do it this way.