打印

[asp] 如何用button获取checkbox的值?

有一复选框:
  <form name="form1" ....>   
   <input type="checkbox" name="choice" id="choice" value="yes"  <%if rs1("product_choice")=true then response.Write "checked" end if%>/>
button按钮:
   <input type="button" name="ok" value="确定" onclick="javascript:location.href='product_choice.asp?id=<%=rs1("id")%>&choice=<%=request.form("choice")%>'">
    ....
  </form>
请教:
  为何choice=<%=request.form("choice")%>获取不到值???

以下是product_choice.asp代码:
<%dim rs,newid,choice
choice=request.querystring("choice")
newid=request.querystring("id")
set rs=....
rs.open "select * from product where id="&newid,conn,1,3
if choice="yes" then
  rs("product_choice")=true
else
  rs("product_choice")=false
end if
rs.update
rs.close
set rs=nothing%>

请高手不辞赐教!
用 js 取,页面没有回发,asp 取不到的。
修行的魔法师
如何取?请给代码,谢谢.
我对js不熟悉,呵呵...
<form name="form1" ....>
    <input type="checkbox" name="choice" id="choice" value="yes"  <%if rs1("product_choice")=true then response.Write "checked" end if%>>
   <input type="button" name="ok" value="确定" onclick="test1();">
</form>
<script language="javascript">
function test1(){
    document.form1.action='?id=<%=rs1("id")%>&choice='+document.getElementById("choice").value;
       document.form1.submit();
}
</script>
www.1715.cn

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!

如何用button获取checkbox的值?

小小菜刀你好:
用你的js终于可以获取到choice的值了,向你表示感谢!
可是,为什么获取的choice的值一直都是"yes"呢?
我的choice是这样的:<input type="checkbox" name="choice" value="yes" <%if rs1("product_choice")=true then response.write"checked" end if%>>
其他的请参考一楼的代码,谢谢!

因为我获取到值后要到提交另一页面product_choice.asp(代码见1楼)处理:
document.form1.action='product_choice.asp?id=<%=rs1("id")%>&Curpage=<%=request.QueryString("Curpage")%>&BigClassName=<%=request.QueryString("BigClassName")%>&choice='+document.getElementById("choice").value;
    document.form1.submit();

现在无论我是否点击复选框,获取的值都是"yes",请指点...

[ 本帖最后由 nicechlk 于 2008-6-20 12:44 编辑 ]

TOP

可能是后面的条件一直成立,
传过去的值应该一直就是yes了。

[ 本帖最后由 z26186 于 2008-6-20 14:13 编辑 ]

TOP

以上的原因,是少了一个判断,看代码:
<%dim choice
choice=request.Form("choice")%>
<script language="javascript">
       function recieve()
       {
              if(document.getElementById("choice").value!="")
              {
                     document.form1.action="product_choice.asp?id=<%=rs1("id")%>&choice="+document.getElementById("choice").value;
              }
              else
              {
                     document.form1.action="product_choice.asp?id=<%=rs1("id")%>";
              }
              document.form1.submit();
              }
              </script>

但是,为什么程序提示缺少 ')' 呢?

TOP

为什么呢这是??

TOP

没有高手了吗????
斑竹呢?不能这样对待我们热心的fans啊!

TOP