PHP技術(shù)進階 用PHP處理多個同名復(fù)選框_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:解決RHAS3中Apache2PHP上傳大小限制近日將論壇從VBB2升級到VBB3,將上傳附件大小設(shè)置為2M,可每次上傳超過500K的附件都會出錯,而之前使用VBB2時卻正常。 仔細檢查php.ini,其中的upload_max_filesize=8m,沒有任何問題,然后將
如果一個表單中有多個同名復(fù)選框,在提交到php時卻只有一個值,而并不像asp那樣是一串用逗號分割的值。有一個很簡單的方法來解決:將復(fù)選框的name后面加上[],例如:<input type="checkbox" name="ccc" value="1"> 改為:<input type="checkbox" name="ccc[]" value="1">。這樣php將得到一個叫ccc的陣列。但這種方法有個問題,如果您要在客戶端對復(fù)選框是否被選擇、選擇了幾個用javascript來判斷時,javascript會因為復(fù)選框的name中含有[]而出錯。您可以在表單中加入一個隱含域,用javascript設(shè)置它的值。
<script language="javascript"> function check() { var strchoice=""; for(var i=0;i<document.news.choice.length;i ) { if (document.news.choice[i].checked) { strchoice=strchoice document.news.choice[i].value ","; } } if (!document.news.choice.length) { if (document.news.choice.checked) { strchoice=document.news.choice[i].value; "," } } strchoice=strchoice.substring(0,strchoice.length-1); document.news.choiceid.value=strchoice; alert(document.news.choiceall.value); } </script> <html> ... <form name="news" action="test.php" method="post" > <input type="checkbox" name="choice" value="1"> <input type="checkbox" name="choice" value="2"> <input type="checkbox" name="choice" value="3"> <input type="checkbox" name="choice" value="4"> <input type="hidden" name="choiceid" value=""> </form> ... </html> |
分享:如何才能將數(shù)據(jù)從文本導(dǎo)入到mysql數(shù)據(jù)庫access中可以將文本中的數(shù)據(jù)輕松導(dǎo)入表中,mysql中用起來沒那么方便,其實起來也很簡單。 首先將數(shù)據(jù)記錄按行處理好用特定的字符分開如:“,” 記錄形如: aaa,bbb,ccc,ddd,eee f
相關(guān)PHP教程:
- 相關(guān)鏈接:
- 教程說明:
PHP教程-PHP技術(shù)進階 用PHP處理多個同名復(fù)選框。