注册 登录
编程论坛 ASP技术论坛

ASP的编程问题

陆嘉文 发布于 2011-12-14 22:12, 580 次点击
<%
player=request("choice")
if player=1 or player=2 or player=3 then
  select case player
    case 1
      mychoice="石头"
    case 2
      mychoice="剪子"
    case 3
      mychoice="布"
  end select
   randomize
  Computer=int(rnd*3)+1
 select case Computer
    case 1
      choice="石头"
    case 2
      choice="剪子"
    case 3
      choice="布"
  end select
  if player-Computer=0 then
    pp="平手!"
  elseif player-Computer=-1 or player-Computer=2 then
    pp="恭喜你,你赢了!"
  else
    pp="这次电脑赢了!"
  end if
end if
%>
<html>
  <title>石头、剪子、布小游戏</title>
  <body> <Center>
    <table border=1 align=center >
      <COL span=2 width=100>
      <tr align=center><td>玩家<td>电脑
      <tr align=center><td><%=mychoice%><td><%=choice%></tr>
      <tr align=center><td colspan=2><%=pp%></tr>
    </table>
    <hr>
    <form action=lx8_3.asp method=post name=f1>请选择:
      <input type=radio name=choice value=1>石头
      <input type=radio name=choice value=2>剪子
      <input type=radio name=choice value=3>布<p>
      <script for=choice event=onclick language=vbscript>
        f1.submit
      </script>
    </form>
  </body>
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录

</html>
谁能说一下,这个代码
<tr align=center><td><%=mychoice%><td><%=choice%></tr>
      <tr align=center><td colspan=2><%=pp%></tr>,是什么意思啊?为什么加<% %>啊/还有啊<script for=choice event=onclick language=vbscript>
        f1.submit
      </script>
为什么用<script>标记,而不用<% %>标记呢?
1 回复
#2
icecool2011-12-15 08:34
</script>标记的是本地客户端脚本,
<% %>标记的是运行在服务器上的。

<tr align=center><td colspan=2><%=pp%></tr>,这里<%=pp%>是比赛结果,上文有设定好的:
程序代码:
if player-Computer=0 then
    pp="平手!"
  elseif player-Computer=-1 or player-Computer=2 then
    pp="恭喜你,你赢了!"
  else
    pp="这次电脑赢了!"
  end if
end if
1