Sweetalert2 Swal.mixin - 是否可以将输入数据提取到 json / php?
Sweetalert2 Swal.mixin - is it possible to extract input data to json / php?
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}</code></pre>
`,
confirmButtonText: 'Lovely!'
})
}
})
在这种情况下,我的答案是:
["1","1","2"]
它怎么会接收到php文件中传递的值呢?
我对这两个科目都不太了解,但我正在经历这种需要。
对不起,对不起我的英语。
更新:
使用此代码:Sweet Alerts - Queue form
为 Swal.fire
找零钱
var strAns1;
var strAns2;
swal.mixin({
input: 'text',
confirmButtonText: 'Next →',
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+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
改变
swal({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
To
Swal.fire({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
我得到的结果是:
{"value":["adf","fffff"]}
Answer1- adf
Answer2- fffff
现在我可以将它传递给 php 吗?
比如?
非常感谢。
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}</code></pre>
`,
confirmButtonText: 'Lovely!'
})
}
})
在这种情况下,我的答案是:
["1","1","2"]
它怎么会接收到php文件中传递的值呢? 我对这两个科目都不太了解,但我正在经历这种需要。 对不起,对不起我的英语。
更新:
使用此代码:Sweet Alerts - Queue form 为 Swal.fire
找零钱 var strAns1;
var strAns2;
swal.mixin({
input: 'text',
confirmButtonText: 'Next →',
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+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
改变
swal({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
To
Swal.fire({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
我得到的结果是:
{"value":["adf","fffff"]}
Answer1- adf
Answer2- fffff
现在我可以将它传递给 php 吗? 比如? 非常感谢。