回 帖 发 新 帖 刷新版面

主题:[原创]如何将<script>中的值传给<%%>中

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>主界面</title>
<script language="JavaScript" type="text/JavaScript">
function sn(){
[color=FF0000]a[/color]=document.form1.xz.value;
}
</script>
</head>

<body>
<table width="780" align="center" cellpadding="0" cellspacing="0" rules="groups">
  <tr>
    <td><form action="mainasp.asp" method="post" name="form1" target="sn">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td width="51%" align="right">操作选项: </td>
            <td width="49%" align="left">
              <select name="xz" id="xz" onChange="sn()"> 
                <option value="开户" selected>开户</option>
                <option value="上机">上机</option>
                <option value="查询">查询</option>
                <option value="充值">充值</option>
                <option value="退卡">退卡</option>
                <option value="挂失">挂失</option>
                <option value="解挂">解挂</option>
              </select></td>
          </tr>
          <%
                     if ([color=FF0000]a[/color]="开户" or [color=FF0000]a[/color]="查询") then
          %>
          <%else%>
          <tr> 
            <td align="right">卡号: </td>
            <td align="left"> 
              <input name="card" type="text" id="card3"></td>
          </tr>
          <tr> 
            <td align="right">密码: </td>
            <td align="left"> 
              <input name="pwd" type="password" id="paw2"></td>
          </tr>
                    <%
          end if
          %>
          <tr> 
            <td colspan="2" align="center"> <input type="submit" name="Submit3" value="确定"> 
              <input type="reset" name="Submit4" value="重置"> <input name="Submit2" type="button" onClick="MM_goToURL('parent','xiaji.asp');return document.MM_returnValue" value="退出"> 
            </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<div align="center"> 
  <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><iframe frameborder="0" width="780" height="450" hspace="0" marginheight="0" marginwidth="0" vspace="0" name="sn" scrolling="auto">此块是iframe嵌套,您的浏览器不支持</iframe></td>
    </tr>
  </table>
</div>
</body>
</html>

回复列表 (共5个回复)

沙发

你这个页面不需要将javascript传给<%%>,只要根据a的值显示和隐藏(卡号和密码)的代码就可以实现了。

板凳

[quote]你这个页面不需要将javascript传给<%%>,只要根据a的值显示和隐藏(卡号和密码)的代码就可以实现了。[/quote]
理论上是这样的,但是在"xz"中选择下拉列表时,卡号和密码并不会根据需要进行显示和隐藏。

3 楼

需要你自己写代码实现

4 楼

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>主界面</title>
<script language="JavaScript" type="text/JavaScript">
function sn1()
{
for(i=0;i<document.form1.xz.options.length;i++)
{
 if(document.form1.xz.options[i].selected==true)
 {
  a=document.form1.xz.options[i].value;
  if(a=="开户"||a=="查询")
  {
    document.getElementById("a1").style.display="block";
    document.getElementById("a2").style.display="block";
  }
  else
  {
   document.getElementById("a1").style.display="none";
   document.getElementById("a2").style.display="none";
  }
 }
}
}
</script>
</head>

<body>
<table width="780" align="center" cellpadding="0" cellspacing="0" rules="groups">
  <tr>
    <td><form action="mainasp.asp" method="post" name="form1" target="sn">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td width="51%" align="right">操作选项: </td>
            <td width="49%" align="left">
              <select name="xz" onChange="sn1()"> 
                <option value="开户" selected>开户</option>
                <option value="上机">上机</option>
                <option value="查询">查询</option>
                <option value="充值">充值</option>
                <option value="退卡">退卡</option>
                <option value="挂失">挂失</option>
                <option value="解挂">解挂</option>
              </select></td>
          </tr>

          <tr id="a1" style="display:none"> 
            <td align="right">卡号: </td>
            <td align="left"> 
              <input name="card" type="text" id="card3"></td>
          </tr>
          <tr id="a2" style="display:none"> 
            <td align="right">密码: </td>
            <td align="left"> 
              <input name="pwd" type="password" id="paw2"></td>
          </tr>

          <tr> 
            <td colspan="2" align="center"> <input type="submit" name="Submit3" value="确定"> 
              <input type="reset" name="Submit4" value="重置"> <input name="Submit2" type="button" onClick="MM_goToURL('parent','xiaji.asp');return document.MM_returnValue" value="退出"> 
            </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<div align="center"> 
  <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><iframe frameborder="0" width="780" height="450" hspace="0" marginheight="0" marginwidth="0" vspace="0" name="sn" scrolling="auto">此块是iframe嵌套,您的浏览器不支持</iframe></td>
    </tr>
  </table>
</div>
</body>
</html>

5 楼


不错,解决了。谢谢!

我来回复

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