![](/img/trans.png)
[英]PHP + MySQL WHERE EXISTS find_in_set returning all values
[英]Find all textbox values and post into PHP MySQL
我只是jQuery的新手,有人可以幫助我嗎?
我想創建一個像這樣的發票系統
我需要做的就是添加一個提交按鈕,該按鈕可以執行以下操作
。查找由某些唯一ID標識的textarea的所有輸入
然后將該值發布到php MySQl earch行中,將包含unueue數據。
無論如何,在您的問題中存在歧義將使您獲得所有文本框的值數組
$(document).ready(function(){
$('#somebuttonid').click(function(){
var tbarray = new Array();
$('.yourtextboxclass').each(function(){
tbarray.push($(this).val()); //You will have a array tbarray with all the values of textboxes
}):
$('#somehiddenelementid').val(tbarray);
$('#somehiddenelementidcontainingform').submit(); //Make sure your action is set,you can access like $_post['$somehiddenelmentname'];
});
});
<!--html side-->
<form id="somehiddenelementidcontainingform" action="youraction" method="post">
<input type="hidden" name="somehiddenelmentname[]" id="somehiddenelementid" />
</form>
我很驚訝地發現,以這種方式措辭的此功能並未帶回大量帶有明顯答案的帖子。
阿曼努拉(Amanullah)的很多評論都要求您先自己嘗試一下,因為人們通常不喜歡回答可谷歌搜索的問題。
我本來會建議這樣做,但是當我用您的關鍵字進行搜索時,沒有明顯的答案。
要序列化所有輸入元素,可以使用:
$('form :input').serialize()
//創建查詢字符串tb1 = bob&tb2 = smith
$('form :input').serializeArray()
//創建一個JSON對象[{name:“ tb1”,value:“ bob},{name:” tb2“,value:” smith“}]
請注意,這些按元素名稱而不是ID傳遞。 值序列化后,可以將其發送到服務器。 如果只想獲取文本框,請將選擇器更改為$('form :input:text')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.