背景信息位 - 我們使用的系統的開發人員已離開公司,並且我被要求添加一些新功能。不用說,沒有文檔,更糟糕的是我是一個絕對的新手,所以我必須學習,因爲我一直在前進。我有點努力做大部分事情,但總是陷入這個問題。對於任何有足夠的幫助我的人來說,如果你真的能夠愚蠢地回答那些很好的答案。所以,問題........獲取並傳遞來自Javascript的數組值
動態填充項目列表的HTML頁面。對於列表中的每個項目都有一個複選框,對於每個勾選的複選框,我需要更新一個MySQL數據庫。這增加了複選框的頁面的代碼是
echo("<td class=\"tableRight\" style=\"width: 5%\"><input type=\"checkbox\" name=\"costume[]\" value=\"".$costume['id']."\" id=\"costume_".$costume['id']."\" onclick=\"tickrow(".$costume['id'].");\" /></td>");
JavaScript文件是在頁面頭部裝有
<script src=\"costume-list.js\" type=\"text/javascript\"></script>
按鈕的代碼應該踢關閉數據庫更新
echo("<div class=\"navContainer\" onClick=\"batch_move() \" class=\"navItem\">");
echo("<img src=\"/resource/img/icon/move.png\" border=\"0\" /><br />Batch Move Costumes");
echo("</a></div>");
最後,我設法放在一起的JavaScript是
function batch_move() {
var combo = document.getElementById("cbo_title");
var move_to = combo.options[combo.selectedIndex].text;
var move_to_id = combo.options[combo.selectedIndex].value;
if (move_to.length==0) {
alert("Please select the location you want to move the costumes to.");
return;
}
var resp_move = confirm("Are you sure you want to MOVE the selected costumes to "+move_to+" ?");
if (resp_move==true) {
alert("Lets move em");
window.open ("http://path-to-server/costume/batch-move-costume.php? loc="+move_to_id+"&items="+INeedTheArrayHere,"mywindow","menubar=1,resizable=1,width=350,height=250");
}
}
所以我想要做的是首先要確保至少有一個複選框被選中並且如果是則得到的勾選框的值到一個數組傳遞給被叫PHP形式。我可以在打開的表單中管理更新代碼,只需將數組添加到它。
對不起,對於很長的文章,但希望這是足夠的信息。如果還有什麼需要了解的,請提問,我會提供更多詳細信息。非常感謝
你可以請加你的HTML也 – Hitesh 2014-12-05 09:07:31