回 帖 发 新 帖 刷新版面

主题:一个文本框A,一个文本框B,在A中输入一串网址,网址中带有id=后面的大约10个左右连续的数字

一个文本框A,一个文本框B,在A中输入一串网址,网址中带有id=后面的大约10个左右连续的数字,提取那10个左右连续的数字到B文本框中,丰应的代码如何加上去?我附上源代码


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>111111111</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<!--打开文本框中URL的JAVA -->
<script language="JavaScript" type="text/javascript">
function Open(){
  var url = document.getElementById("url").value;
  window.open (text.value+text1.value);
}
function clearContent(txt)
{
txt.value="";
}
</script>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>


<body onContextMenu="return false" >
<div align="center">
    <table width="900" border="0" cellspacing="8" background="images/login_border_img01.gif">
      <tr>
        <td height="147" valign="top"><table border="0" align="center" cellspacing="0" bgcolor="#FFFFFF">
          
          <tr>
            <td width="3592" height="66" colspan="2"><table width="900" border="0" align="center" cellspacing="0">
                <tr>
                  <td width="56" align="left">&nbsp;</td>
                  <td width="7" align="left" bgcolor="#88C4FF">&nbsp;</td>
                  <td width="552" bgcolor="#88C4FF"><input name="thisUrl" type="text" onclick="value=';focus()" id="thisUrl" height="8" style="height:25px; color:#666666; line-height:25px;" value="如:http://detail.tmall.com/item.htm?spm=a1z10.1.w7567245.5.uVg1oQ&id=17901080044" size="77"/></td>
                  <td width="42" align="left"><input type="submit" name="Submit" value="提取" /></td>
                  <td width="233" rowspan="3" align="right">&nbsp;</td>
                </tr>
                <tr>
                  <td height="36"></td>
                  <td colspan="2" align="left">点提取按钮,只提取上面网址<span class="STYLE1">ID=</span>后面的数字,然后附给下面的文本框中,<span class="STYLE1">ID=</span>的位置有时会不同</td>
                  <td></td>
                </tr>
                <tr>
                  <td align="left"><label></label></td>
                  <td bgcolor="#88C4FF"><input name="text" type="text" id="url" style="height:25px; color:#CCCCCC; background-color:#88C4FF; line-height:25px; visibility:hidden; " value="http://www.1111111.com/newtb/go.aspx?u=1S11411454&amp;Nid=" size="1" /></td>
                  <td bgcolor="#88C4FF"><input name="text1" type="text" id="text1"  height="8" style="height:25px; color:#666666; line-height:25px; " size="77" /></td>
                  <td align="left"><input name="button" type="button" onclick="Open()" value="打开"  /></td>
                </tr>
            </table></td>
          </tr>
          
          
        </table></td>
      </tr>
    </table>
    <label><br />
  </label>
    <label><br />
  </label>
</div>
</body>
</html>



回复列表 (共2个回复)

沙发

加过程,得用JS, "提取"按钮调这个过程将值赋给B.方法是这样. 但js代码中涉及到字符查询和截取的问题,网上查一下.

板凳

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>111111111</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<!--打开文本框中URL的JAVA -->
<script language="JavaScript" type="text/javascript">
function Open(){
  var url = document.getElementById("url").value;
  window.open (text.value+text1.value);
}
function clearContent(txt)
 {
 txt.value="";
 }
 function f(){
     var url=document.getElementById("thisUrl").value;
     var id="";
     index=url.indexOf("id");
     if(index>=0)
     {
         url=url.substring(index,url.length);
         if(url.indexOf("&")>0)
         {
             index2=url.indexOf("&");
             id=url.substring(3,index2);
         }
         else{
             id=url.substring(3,url.length);
         }
     }
     
    document.getElementById("text1").value=id;
     
 }
</script>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>


<body onContextMenu="return false" >
<div align="center">
    <table width="900" border="0" cellspacing="8" background="images/login_border_img01.gif">
      <tr>
        <td height="147" valign="top"><table border="0" align="center" cellspacing="0" bgcolor="#FFFFFF">
          
          <tr>
            <td width="3592" height="66" colspan="2"><table width="900" border="0" align="center" cellspacing="0">
                <tr>
                  <td width="56" align="left">&nbsp;</td>
                  <td width="7" align="left" bgcolor="#88C4FF">&nbsp;</td>
                  <td width="552" bgcolor="#88C4FF"><input name="thisUrl" type="text" id="thisUrl" height="8" style="height:25px; color:#666666; line-height:25px;" value="如:http://detail.tmall.com/item.htm?spm=a1z10.1.w7567245.5.uVg1oQ&id=17901080044" size="77"/></td>
                  <td width="42" align="left"><input type="submit" name="Submit" value="提取" onclick="f()" /></td>
                  <td width="233" rowspan="3" align="right">&nbsp;</td>
                </tr>
                <tr>
                  <td height="36"></td>
                  <td colspan="2" align="left">点提取按钮,只提取上面网址<span class="STYLE1">ID=</span>后面的数字,然后附给下面的文本框中,<span class="STYLE1">ID=</span>的位置有时会不同</td>
                  <td></td>
                </tr>
                <tr>
                  <td align="left"><label></label></td>
                  <td bgcolor="#88C4FF"><input name="text" type="text" id="url" style="height:25px; color:#CCCCCC; background-color:#88C4FF; line-height:25px; visibility:hidden; " value="http://www.1111111.com/newtb/go.aspx?u=1S11411454&amp;Nid=" size="1" /></td>
                  <td bgcolor="#88C4FF"><input name="text1" type="text" id="text1"  height="8" style="height:25px; color:#666666; line-height:25px; " size="77" /></td>
                  <td align="left"><input name="button" type="button" onclick="Open()" value="打开"  /></td>
                </tr>
            </table></td>
          </tr>
          
          
        </table></td>
      </tr>
    </table>
    <label><br />
  </label>
    <label><br />
  </label>
</div>
</body>
</html>

我来回复

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