Set toast message on select

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
philmills
User
Posts: 535

Set toast message on select

Post by philmills »

On a slight tangent from this topic, hence the new topic:
viewtopic.php?t=54275

Lets say for example my dropdown contains values 1, 2 or 3 and I want a different message displayed based on each value. How do I trigger PHPMaker's alert system from within the jquery code?

if (this.value == "1"){ 
  //show $this->setMessage(Language()->phrase('MyMessage _1'));
 }        
 if (this.value == "2"){ 
//show $this->setMessage(Language()->phrase('MyMessage_2'));
 }
if (this.value == "3"){
//show $this->setMessage(Language()->phrase('MyMessage_2'));
}

mobhar
User
Posts: 11660

Post by mobhar »

You may try:

if (this.value == "1")
  ew.alert(ew.language.phrase("MyMessage _1"));

In addition, make sure you have already defined the MyMessage_1 phrase either in Language_Load server event using setPhrase method with third param = true, or in .xml language file with param client="1", so that the phrase will be able read from client-side.


philmills
User
Posts: 535

Post by philmills »

Thanks, this is working
What also is correct syntax for displayimng the mesage using the bootstrap toast (which looks more polite for some purposes)?


philmills
User
Posts: 535

Post by philmills »

I figured it out

if (this.value == "1"){ 
ew.toast({title:'Info', body:ew.language.phrase("MyMessage_1"), autohide:'false', delay:'5000', animation:'true', class:'toast bg-warning fade show'});
 }        
 if (this.value == "2"){ 
ew.toast({title:'Info', body:ew.language.phrase("MyMessage_2"), autohide:'false', delay:'5000', animation:'true', class:'toast bg-warning fade show'});
 }
if (this.value == "3"){
ew.toast({title:'Info', body:ew.language.phrase("MyMessage_3"), autohide:'false', delay:'5000', animation:'true', class:'toast bg-warning fade show'});
}

Post Reply