[英]how to get select2(plugin) tag value in php
我正在使用select2插件。
我能夠在jquery中獲取所選的tags數組,但是如何將數組附加到DOM中並在表單提交或任何其他方法中獲取php中的值 ?
我的表單中有多個文件上傳,所以我不想要ajax。 這是我正在應用select2
的標簽。
<input type="hidden" id="tags" value="tag" style="width: 400px;">
這是我正在使用的小提琴: http : //jsfiddle.net/X6V2s/66/
我在jquery中有一個值數組但是想在php中使用它。
我可以將數組附加到DOM中(如果是的話那么?怎么樣)
我怎么能這個呢? 請幫我。 提前致謝。
在提交表單之前嘗試設置所選標簽的Cookie。 然后你可以訪問php
cookie
注意:不要忘記在表單提交后刪除cookie。
JS:使用jQuery Cookie有關JQuery cookie的進一步描述,請閱讀此處
$.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');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.