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

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

qlongjun 发布于 2012-11-13 09:58, 1199 次点击
一个文本框A,一个文本框B,在A中输入一串网址,网址中带有id=后面的大约10个左右连续的数字,
提取那10个左右连续的数字到B文本框中,
文本框B有固定了一串网址在前面,从A中提取出来的字符串与B相组合成新网址
只有本站会员才能查看附件,请 登录


这是原代码
程序代码:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" href="css.css" />
<title>无标题文档</title>
<script language="javascript">
function Open(){
  
var url = document.getElementById("url").value;
  window.open (url);
}
function clearContent(txt)
    {
        txt.value
="";
    }
</script>
</head>

<body>
<div align="center">
  <form id="form1" name="form1" method="post" action="">
    <table width="900" border="0">
      <tr>
        <td height="133"><table width="850" border="0" align="center">
          <tr>
            <td width="66" align="left">
              粘贴网址</td>
            <td width="546" align="left" bgcolor="#7C99E2">
            <input name="a1" type="text" id="a1" height="8" style="height:20px;" value="http://item. size="77"/>
            </td>
            <td width="224" align="left">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td align="left"><label>提取ID</label></td>
            <td align="left" bgcolor="#7C99E2"><input name="text" type="text" id="url" height="8" style="height:20px;" value="http://www. size="64"/>
                <input type="submit" name="Submit" value="提取" />
                <input name="button" type="button" onclick="Open()" value="打开" /></td>
            <td align="left">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table>
    <label><br />
      <br />
    </label>
  </form>
</div>
</body>
</html>



请高手上传代码,小弟万公感谢。
5 回复
#2
qlongjun2012-11-17 09:12
顶一下急呀
#3
dzt00012012-11-17 12:43
给你一个JS获取URL指定参数的值
程序代码:
<script language="javascript">
function getURLValue(url, name) {
    var reg = new RegExp('(\\?|&)' + name + '=([^&?]*)', 'i');
    var arr = url.match(reg);

    if (arr) {
        return arr[2];
    }

    return null;
}

alert(getURLValue("http://","id"));
</script>
#4
青春无限2012-11-17 13:31
顶一下
#5
qlongjun2012-11-18 09:50
在提取按钮上面该加什么代码
#6
dzt00012012-11-18 12:13
程序代码:
function pickURL() {
    var URL = document.getElementById("a1").value;
    var newURL = "http://www."+getURLValue(URL, "id");
    document.getElementById("url").value = newURL;
}

按钮:
<input name="button" type="button" onclick="pickURL()" value="提取" />
1