How to put two radio inputs in alert?


#1

below code works perfect, but i need add another radio input for delivery (standard delievery, express delievery), how to add this radio input into the alert?

any hints will be more than welcome!

advanceSearch(): void{
let prompt = this.alertCtrl.create({
title: ‘payment’,
message: 'choose payment ',
inputs : [
{
type:‘radio’,
label:'paypal’
value:‘paypal’
},
{
type:‘radio’,
label:'bank transfer’
value:‘bank transfer’
}

],
buttons : [
{
text: “Cancel”,
handler: data => {
console.log(“cancel clicked”);
}
},
{
text: “Buy”,
handler: data => {
console.log(“Buy clicked”);
}
}
]
});
prompt.present();
}


#2

The same way you’ve done right now? Well, perhaps you’ve just copy pasted code and don’t really understand how it works. In that case, you should try to learn some basics from the docs and tutorials available online.

Just so that you understand whats happening here in your code, you are passing the create method options containing an inputs array with the required radio buttons. You need to add any other radio buttons needed to this array, like the following:

...
inputs: [
   {
      type: 'radio',
      label: 'paypal',
      value: 'paypal'
   },
   {
      type: 'radio', 
      label: 'bank transfer',
      value: 'bank transfer'
   },
   {
      type: 'radio',
      label: 'standard delievery',
      value: 'standard delievery'
   },
   {
      type: 'radio',
      label: 'express delievery',
      value: 'express delievery'
   }
]
...

BTW right now your code is not correct, it’s missing commas after the label properties.

As also, please always format the code you are posting by selecting the code and clicking on the </> button on the tool bar in the editor here.


#3

Thanks for your reply, it is not what i need
i need make one choice for payment between paypal and bank transfer
and another choice for delivery between standard and express .

in short term two choices for two different categories


#4

If you need a very customised interface, then you should look into custom modals perhaps.