回 帖 发 新 帖 刷新版面

主题:ASP学习求助

各位前辈,我是一个学习ASP的新手,遇到个不会的地方,还请各位能帮下。

在一个Function中有个参数price,在一个表单的提交按钮中调用了这个Function,想将这个price与表单中的值一起传到另一网页。可是总是不成功。

function的语句:

function mm(price)
{
    ....
    price=10
}

提交表单中的一些语句:

<form name="form3" method="post" action="getprice.asp">
  <label>
  <input type="submit" name="Submit" value="提交" onClick="mm()">
  </label>
</form>

一直提交不成功。

回复列表 (共9个回复)

沙发

使用隐藏表单就可以了,为什么要放在js中呢?

板凳


因为Price事计算出来的
我这里简写了一点

3 楼

这样试试:

<form name="form3" method="post" action="getprice.asp">
  <label>
  <script language="javascript">
   //这里写上计算的代码
   price=10;
   document.write("<input type=hidden name=price value="+price+">");
  </script>
  <input type="submit" name="Submit" value="提交">
  </label>
</form>

然后在getprice.asp中接收即可:

price=request.form("price")

4 楼

没人回帖了。。。。。楼上方法试了
不成功。

5 楼

function mm(price)
{
    ....
    price=10
}
是js函数还是asp函数不清

6 楼

<script language="javascript">

7 楼

我再把问题完善点吧~~

编写下面代码时候遇到了一个问题,FUNCTION里面的值传不到下面的price的隐藏域中,然后也就传不到index.asp中
想请问下您,该如何修改才能实现
<script language="javascript">
 function ddtz(price)
{
price=0
    var t1 = window.document.form3.c1;
    //var s1 = "";
    if(t1.checked == true)
    {
    price = price + 10;
    }

    var t2 = window.document.form3.c2;
    //var s2 = "";
    if(t2.checked == true)
    {
     price =  price + 5;
    }

    //类似的代码

    var t13 = window.document.form3.c13;
    //var s1 = "";
    if(t13.checked == true)
    {
     price = price + 15;
    }
}
</script>

//下面的代码是

<form id="form3" name="form3"  method="post" action="index.asp">
    <input name="c1" type="checkbox" id="c1" />
    <input name="c2" type="checkbox" id="c2" />
    <input name="c3" type="checkbox" id="c3" />

    //这里类似的代码

    <input name="c13" type="checkbox" id="c13" />
    
    <input type="Submit" name="Submit5" value="提交" onClick="ddtz()" />
    <input name="pirce" type="hidden"  id="pirce" value="" />
</form>

8 楼


<script language="javascript">
 function ddtz(price)
{
price=0
    var t1 = window.document.form3.c1;
    //var s1 = "";
    if(t1.checked == true)
    {
    price = price + 10;
    }

    var t2 = window.document.form3.c2;
    //var s2 = "";
    if(t2.checked == true)
    {
     price =  price + 5;
    }

    //类似的代码

    var t13 = window.document.form3.c13;
    //var s1 = "";
    if(t13.checked == true)
    {
     price = price + 15;
    }
[color=FF0000]window.document.form3.pirce.value=price;[/color]
}
</script>

//下面的代码是

<form id="form3" name="form3"  method="post" action="123.asp">
    <input name="c1" type="checkbox" id="c1" />
    <input name="c2" type="checkbox" id="c2" />
    <input name="c3" type="checkbox" id="c3" />

    //这里类似的代码

    <input name="c13" type="checkbox" id="c13" />
    
    <input type="Submit" name="Submit5" value="提交" onClick="ddtz()" />
    <input name="pirce" type="hidden"  id="pirce" value="" />
</form>

9 楼

谢谢各位,问题终于解决了

我来回复

您尚未登录,请登录后再回复。点此登录或注册