如何在 php 中获取 select2(plugin) 标签值
how to get select2(plugin) tag value in php
我正在使用 select2 插件。
我能够在 jquery 中获取选定的标签数组,但是如何将数组附加到 DOM 中并 在 php 中获取值表单提交 或任何其他方法?
我的表单中有多个文件上传,所以我不想 ajax。
这是我要应用的标签 select2
.
<input type="hidden" id="tags" value="tag" style="width: 400px;">
这是我正在使用的fiddle:http://jsfiddle.net/X6V2s/66/
我在 jquery 中有一组值,但想要在 php 中。
我可以将数组附加到 DOM 中吗(如果是的话?如何)
我怎样才能做到这一点?
请帮我。
提前致谢。
尝试在提交表单之前设置所选标签的 cookie。
那么您可以在 php
中访问 cookie
NOTE: dont forget to remove cookie after form submition.
JS: 使用 jQuery Cookie For further understating about JQuery cookie read here
$.cookie("test", 1, {
expires : 10, //expires in 10 days
path : '/', //The value of the path attribute of the cookie
//(default: path of page that created the cookie).
domain : 'yourdomain.com', //The value of the domain attribute of the cookie
//(default: domain of page that created the cookie).
secure : true //If set to true the secure attribute of the cookie
//will be set and the cookie transmission will
//require a secure protocol (defaults to false).
});
PHP 在服务器端读取 cookie。
echo $_COOKIE('test');
我正在使用 select2 插件。
我能够在 jquery 中获取选定的标签数组,但是如何将数组附加到 DOM 中并 在 php 中获取值表单提交 或任何其他方法?
我的表单中有多个文件上传,所以我不想 ajax。
这是我要应用的标签 select2
.
<input type="hidden" id="tags" value="tag" style="width: 400px;">
这是我正在使用的fiddle:http://jsfiddle.net/X6V2s/66/
我在 jquery 中有一组值,但想要在 php 中。
我可以将数组附加到 DOM 中吗(如果是的话?如何)
我怎样才能做到这一点? 请帮我。 提前致谢。
尝试在提交表单之前设置所选标签的 cookie。
那么您可以在 php
NOTE: dont forget to remove cookie after form submition.
JS: 使用 jQuery Cookie For further understating about JQuery cookie read here
$.cookie("test", 1, {
expires : 10, //expires in 10 days
path : '/', //The value of the path attribute of the cookie
//(default: path of page that created the cookie).
domain : 'yourdomain.com', //The value of the domain attribute of the cookie
//(default: domain of page that created the cookie).
secure : true //If set to true the secure attribute of the cookie
//will be set and the cookie transmission will
//require a secure protocol (defaults to false).
});
PHP 在服务器端读取 cookie。
echo $_COOKIE('test');