获取隐藏字段

时间:2015-07-10 11:54:36

标签: javascript java css html5 jsp

我的页面上有170个按钮。如果点击按钮然后颜色改变了,我也将该按钮的id存储在java字符串数组中以便在database.i中更新。可以使用隐藏字段来访问按钮id。如果我得到按钮ID,那么页面将刷新然后颜色按钮改变。所以请帮我解决这个问题,请帮帮我

enter code here

   <script>     

        <%int index = 0;%>

        //FUNCTION CALL IF BUTTONS CLICKED
        function sub(id) {
            if (ss < pp) {
                if (document.getElementById(id).style.background == "") {
                    document.getElementById(id).style.background = "#ff0000";
                    ss++;
                    //HIDDEN IS THE ID OF HIDDEN TAG...
                    var val = document.getElementById("hidden");
                    val.value = id;
                    //THIS IS MY JAVA CODE.. IN THIS I SHALL CONNECT TO DATABASE AND ENTRY IN DB USING UPDATE VARIABLE
        <%

         String[] update = new String[100];
         if (request.getParameter("hidden") != null) {
             update[index] = request.getParameter("hidden");

         }
        %>
                }
                else {
                    document.getElementById(id).style.background = "";
                    ss--;

                }
                if (ss == pp) {
                    if (document.getElementById(id).style.background == "") {
                        alert("exceed!!");
                    }
                    else {
                        document.getElementById(id).style.background = "";
                        ss--;

                    }

                }

            }

        }

0 个答案:

没有答案