Page 1 of 1

Message Box

Posted: 2020-03-04 01:42
by dharbitindy
Does anyone know how to make a message box pop up if a condition is met? For instance, if a value is >= 100.00 then popup a message box that states "This value is too high, check your data input". This doesn't have to stop input, or throw an error, just a warning message.

Thank you,
David

Re: Message Box

Posted: 2020-03-04 07:10
by pbottcher
Hi,

you can try to use:

Code: Select all

	show_notification({
			message: "YOUR MESSAGE HERE",
			class: 'danger',
			dismiss_seconds: 30
			});

Re: Message Box

Posted: 2020-03-04 14:01
by dharbitindy
Thank you Pascal,

One other thing. Where would be best to put this code? and would this be appropriate?

if($j('#eff_percent').val() >= 100.00)
show_notification({
message: "This is High. Please check your data",
class: 'danger',
dismiss_seconds: 300
});

Thanks again,
David

Re: Message Box

Posted: 2020-03-04 17:07
by D Oliveira
javascript


alert box

Code: Select all

alert('MESSAGE HERE');

confirm box

Code: Select all

var txt;
var r = confirm("Are you sure?");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}

Re: Message Box

Posted: 2020-03-04 18:08
by dharbitindy
Much appreciated, but where would this code need to be placed?

Thank you,
David

Re: Message Box

Posted: 2020-03-04 18:59
by dharbitindy
Screen shots;

One is the eff.php file and the other is the eff Detail View.

Thank you,
David

Re: Message Box

Posted: 2020-03-04 20:03
by D Oliveira
dharbitindy wrote:
2020-03-04 18:59
Screen shots;

One is the eff.php file and the other is the eff Detail View.

Thank you,
David

hooks/eff-dv.js

Code: Select all

$j(function{

if ( $j('#eff_percent').val() >= 100 ){
alert('This is High. Please check your data');
}

});

Re: Message Box

Posted: 2020-03-04 21:18
by dharbitindy
Thank you! I'll give it a try. Much appreciated.

David

Re: Message Box

Posted: 2020-03-05 02:28
by dharbitindy
D Oliveira,

Thank you, but this unfortunately didn't show a message. I appreciate your input though.

David

Re: Message Box

Posted: 2020-03-05 17:41
by D Oliveira
dharbitindy wrote:
2020-03-05 02:28
D Oliveira,

Thank you, but this unfortunately didn't show a message. I appreciate your input though.

David
try this:

Code: Select all

$j('#eff_percent').on('change', function(){
if ( $j('#eff_percent').val() >= 100 ){
alert('This is High. Please check your data');
}
});

Re: Message Box

Posted: 2020-03-05 18:39
by dharbitindy
This did show the message if I change the value of the eff_percent field however; that is a calculated field so, I think that if I do the calculation in AppGini rather than in the eff.php file, this eff-dv.js code may work. I'll try that and let you know.

Thank you,
David

Re: Message Box

Posted: 2020-03-05 19:37
by dharbitindy
Unfortunately that didn't work correctly either. Unless the calculated field value changes (eff_percent) when either the good_parts, or the hrs_ran value(s) change, the message won't show up correctly. It's definitely closer, but not quite working yet. Thanks again though.

David

Re: Message Box

Posted: 2020-03-06 03:39
by D Oliveira
dharbitindy wrote:
2020-03-05 19:37
Unfortunately that didn't work correctly either. Unless the calculated field value changes (eff_percent) when either the good_parts, or the hrs_ran value(s) change, the message won't show up correctly. It's definitely closer, but not quite working yet. Thanks again though.

David
try calculating the field through javascript instead of using appgini built in function.

Code: Select all

$j('#field_a, #field_b').on('change', function(){

	var sum_total = Number($j('#field_a').val()) + Number($j('#field_b').val()) ; // use + or - or / or *
	
	$j('#eff_percent').val(sum_total);
	
	if ( $j('#eff_percent').val() >= 100 ){
		alert('This is High. Please check your data');
	}
	

});


$j('#eff_percent').on('change', function(){
	if ( $j('#eff_percent').val() >= 100 ){
		alert('This is High. Please check your data');
	}
});


Re: Message Box

Posted: 2020-03-06 17:15
by dharbitindy
Thank you sir! I'll try it.

David