日期:2014-05-17 浏览次数:20739 次
<html>
<body>
<input id="phone_num" />
<input type="button" id="btn_submit" value="提交"/>
<div id="result"></div>
<script>
var $ = function(id){return document.getElementById(id);}
$('btn_submit').onclick = function(){
var src = "http://www.xxxx.com/sds/sdfsd?fsdsdfr.eft.com";
$('result').innerHTML = src.replace(/sdsd/, "sd"+$('phone_num').value+"sd");
}
</script>
</body>
</html>
------解决方案--------------------
<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script>
function test(){
var tel = document.form.phone.value;
alert("phone-->>"+tel);
var url = "http://www.xxxx.com/sds/sdfsd?fsd"+tel+"sdfr.eft.com";
alert("url-->>"+url);
}
</script>
<form name="form" action="" method="post">
<input type="text" name="phone" />
<input type="button" name="submit" value="submit" onclick="test()" />
</form>
</body>
</html>