出来るのだASP Q&A掲示板(過去LOG)
訪問数 52046
昨日 889
今日 776 【PR】 パソコン入門からIT専門書まで幅広く取り揃えています。セブン-イレブン受取り手数料無料のセブンアンドワイ。 |
![]() ![]() ![]() ![]() ![]() |
[4706] Re:チェックボックスのOff時の値を取得して配列に渡したい |
投稿者:はまぐりんさん 2004/10/22 5:16:37 |
> <!--// > function check(){ > if (document.cart.del.length){ > for(i = 0; i < document.cart.del.length; i++) > { > if (document.cart.del[i].checked == ture) > document.cart.del.value = "delete"; > if (document.cart.del[i].checked == false) > document.cart.del.value = "keep"; > } > } > else{ > if (document.cart.del.checked == ture) > document.cart.del.value = "delete"; > if (document.cart.del.checked == false) > document.cart.del.value = "keep"; > } > } > > 初めのif文で、複数なのか1個しかないのか判断 > 複数の場合は配列をループでまわしてvalue設定 > 1個しかないならそれにvalue設定 > 配列の場合と1個の場合で切り分ける必要があるんでめんどくさいんです。・・・多分これでうまくいくと思う コードとご説明を書いていただいて、ありがとうございます。 これで試してみましたが、だめでした。。。 どうしてもKeepが飛んできません! こういう場合。CheckboxにはValueをしておかなくてもいいですよね? どちらも試してみましたが、だめでした。 今、コードは以下のようになっています。(u_id(i)とs_del(i)の値を表示するようにしてあります。) <input hidden>で値を渡すにしてみたんですが、DeleteもKeepも何も飛んできません。。。 ちなみに、<input hidden>を使わずに<checkbox>だけでも試してみましたが、だめでした。 <script language="JavaScript"> <!--// function check(){ if (document.cart.del2.length){ for(i = 0; i < document.cart.del2.length; i++) { if (document.cart.del2[i].checked == true) document.cart.del.value = "delete"; if (document.cart.del2[i].checked == false) document.cart.del.value = "keep"; } } else{ if (document.cart.del2.checked == true) document.cart.del.value = "delete"; if (document.cart.del2.checked == false) document.cart.del.value = "keep"; } } // --> </script> <tr> <td height="5" colspan="2"> <div align="right"><font size="2" face="MS Pゴシック, Osaka"><a href="mail_order_top.asp"><br> メールオーダートップ</a> | <a href="mail_order_special.asp">特売品コーナー</a> | <a href="mail_order.asp?act=checkout&id=<%= cus_id %>">チェックアウト</a> </font></div> </td> </tr> <tr valign="top"> <td height="217" colspan="2"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" height="16"><img src="Pic/MailOrder/ShoppingCart/shopping_cart_title.gif" width="762" height="67"></td> </tr> <tr valign="top"> <td height="266" colspan="3"><font size="2" face="MS Pゴシック, Osaka"><br> <br> お客様のショッピングカートの中身は下記の通りです。</font><br> <br> <form method="post" action="mail_order.asp?act=update&id=<%= ObjRS("cus_id") %>" name="cart"> <table width="760" bordercolor="#666666" border="1" cellspacing="0"> <tr> <td width="33" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">削除</font></div> </td> <td width="58" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">商品番号</font></div> </td> <td width="395" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">商品名</font></div> </td> <td width="35" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">個数</font></div> </td> <td width="63" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">単価</font></div> </td> <td width="72" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">重量</font></div> </td> <td width="74" height="10" nowrap> <div align="center"><font size="2" face="MS Pゴシック, Osaka">合計金額</font></div> </td> </tr> <% Do Until ObjRS.eof If ObjRS("special") = "1" then color = "#ff0000" else color = "#000000" end if %> <tr> <td width="33" height="18"> <div align="center"> <input type="checkbox" name="del2"> </div> </td> <td width="58" height="18"><font size="2"><%= ObjRS("prod_num") %></font></td> <td width="395" height="18"><font size="2"><%= ObjRS("prod_name") %></font></td> <td width="35" height="18" align="left"> <div align="center" align="left"> <font size="2"><input type="text" name="qty" size="4" maxlength="4" value="<%= ObjRS("qty") %>"></font> </div> </td> <td width="63" height="18" align="right"><font size="2" color="<%= color %>">$<%= ObjRS("unit_price") %></font></td> <td width="72" height="18" align="center"><font size="2"><%= ObjRS("total_wei") %> Lbs</font></td> <td width="74" height="18" align="right"><font size="2" color="<%= color %>">$<%= FormatNumber(ObjRS("total_price")) %></font></td> </tr> <input type="hidden" name="del"> <input type="hidden" name="prod_id" value="<%= ObjRS("id") %>"> <input type="hidden" name="prod_num" value="<%= ObjRS("prod_num") %>" > <input type="hidden" name="prod_name" value="<%= ObjRS("prod_name") %>" > <input type="hidden" name="unit_price" value="<%= ObjRS("unit_price") %>" > <input type="hidden" name="wei" value="<%= ObjRS("wei") %>" > <input type="hidden" name="total_price" value="<%= ObjRS("total_price") %>"> <input type="hidden" name="category" value="<%= ObjRS("category") %>"> <% total_price = ObjRS("total_price") t_t_price = FormatNumber(t_t_price + total_price, 2) ObjRS.MoveNext Loop <tr> <td colspan="6" align="right"><font size="2">小合計金額</font></td> <td align="right"><font size="2">$<%= t_t_price %></font></td> </tr> <% ObjRS.Close Set ObjRS = Nothing ObjConn.Close Set ObjConn = Nothing Set ObjConn = Server.CreateObject("ADODB.Connection") ObjConn.open "driver={Microsoft Access Driver (*.mdb)}; DBQ=" & _ Server.Mappath("../Data/mail_order.mdb") Set ObjRS = Server.CreateObject("ADODB.Recordset") StrSQL = "select * from shopping where cus_id=" & cus_id ObjRS.Open StrSQL, ObjConn %> </table> <table width="760" border="0"> <tr> <td align="right" width="530"><input type="image" src="pic/mailorder/update.jpg" name="act" onClick = "check()"></td> </form> <form method="post" action="mail_order_top.asp"> <td align="right" width="130"><input type="image" src="pic/mailorder/shopping.jpg" name="act"></td> </form> <form method="post" action="mail_order.asp?act=checkout&id=<%= ObjRS("cus_id") %>"> <td align="left" width="100"><input type="image" src="pic/mailorder/checkout.jpg" name="act"></td> </form> </tr> </table> </td> </tr> </table> <% end if %> </td> </tr> <tr> <td height="71" colspan="2"> <div align="center"><font size="2" face="MS Pゴシック, Osaka"><a href="mail_order_top.asp">メールオーダートップ</a> | <a href="mail_order_special.asp">特売品コーナー</a></font><br> </div> <hr align="center"> </td> </tr> <% ObjRS.Close Set ObjRS = Nothing ObjConn.Close Set ObjConn = Nothing End Sub ' カートの中身を更新 Sub Update Set ObjConn = Server.CreateObject("ADODB.Connection") ObjConn.open "driver={Microsoft Access Driver (*.mdb)}; DBQ=" & _ Server.Mappath("../Data/mail_order.mdb") cus_id = Request.QueryString("id") del = Request.Form("del") s_del = split(del, ",") prod_id = Request.Form("prod_id") u_id = split(prod_id, ",") qty = Request.Form("qty") u_qty = split(qty, ",") wei = Request.Form("wei") u_wei = split(wei, ",") unit_price = Request.Form("unit_price") u_unit_price = split(unit_price, ",") for i = 0 to UBound(u_id) Response.Write u_id(i) & "<br>" Response.Write s_del(i) & "<br>" Set ObjRS = Server.CreateObject("ADODB.Recordset") StrSQL = "select * from shopping where cus_id =" & cus_id & " and id = " & u_id(i) ObjRS.Open StrSQL, ObjConn, 3, 3 ObjRS("qty") = u_qty(i) ObjRS("wei") = u_wei(i) ObjRS("total_wei") = FormatNumber(u_wei(i) * u_qty(i)) ObjRS("total_price") = FormatNumber(u_unit_price(i) * u_qty(i),2) ObjRS("tax") = ObjRS("total_price") * tax_rate ObjRS.Update Next ObjRS.Close Set ObjRS = Nothing ObjConn.Close Set ObjConn = Nothing End Sub %> 何度も何度も申し訳ありませんが、宜しくお願いします。 |
![]() ![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
TreeBBS For ASP V.0.1.3 |