Sweetalert2 Swal.mixin - возможно ли извлечь входные данные в json / php? - PullRequest
0 голосов
/ 22 января 2020
Using this code:
Swal.mixin({
  input: 'text',
  confirmButtonText: 'Next →',
  showCancelButton: true,
  progressSteps: ['1', '2', '3']
}).queue([
  {
    title: 'Question 1',
    text: 'Chaining swal2 modals is easy'
  },
  'Question 2',
  'Question 3'
]).then((result) => {
  if (result.value) {
    const answers = JSON.stringify(result.value)
    Swal.fire({
      title: 'All done!',
      html: `
        Your answers:
        <pre><code>${answers}
`, подтвердитеButtonText: 'Прекрасно!' })}})

В этом случае мои ответы:

["1","1","2"]

как он может получить значения, переданные в файле php? Я плохо знаю оба предмета, но испытываю эту потребность. Извините, и извините за мой английский sh.

1 Ответ

0 голосов
/ 22 января 2020

Обновление:

Использование этого кода: Сладкие оповещения - Форма очереди Внести изменения в Swal.fire

<code>  var strAns1;
    var strAns2;

    swal.mixin({
      input: 'text',
      confirmButtonText: 'Next &rarr;',
      showCancelButton: true,
      progressSteps: ['1', '2', '3']
    }).queue([
      {
        title: 'Question 1',
        text: 'Chaining swal2 modals is easy',
        preConfirm: function(value)
                {
                    strAns1= value;
                }
      },

      {
        title: 'Question 2',
        text: 'Chaining swal2 modals is easy',
        preConfirm: function(value)
                {
                    strAns2= value;
                }
      }
    ]).then((result) => {
      if (result.value) {
        Swal.fire({
          title: 'All done!',
          html:
            'Your answers: <pre>' +
              JSON.stringify(result) +
            '<pre>Answer1- ' + strAns1+
            '<pre>Answer2- ' + strAns2+
            '
', verifyButtonText:' Lovely! ' })}})

Изменить

<code>swal({
      title: 'All done!',
      html:
        'Your answers: <pre>' +
          JSON.stringify(result) +
        '<pre>Answer1- ' + strAns1+
        '<pre>Answer2- ' + strAns2+
        '
', verifyButtonText:' Lovely! ' })}}) To Swal.fire ({title: 'All done!', html: 'Your answers:
' +
          JSON.stringify(result) +
        '<pre>Answer1- ' + strAns1+
        '<pre>Answer2- ' + strAns2+
        '
', verifyButtonText: 'Lovely!'})}})

Я получаю в результате это:

{"value":["adf","fffff"]}
Answer1- adf
Answer2- fffff

Теперь я могу передать это php? Как например? Спасибо большое спасибо.

...