<DIV id=fm>
<form name="free" method="get" action='news.php' >
<input type="text" name=edit class="STYLE2" id=kw maxlength=150>
<SPAN class=btn_wr>
<INPUT type="submit" class=btn id=su
value="检 索" >
</SPAN>
</FORM>
</DIV>
首先判断输入框edit的内容是否为空,若非空跳转到news.php页面,且把值传给news.php中的edit2。
该怎么写。本人是PHP初学,请大哥大姐指点
<form name="free" method="get" action='news.php' >
<input type="text" name=edit class="STYLE2" id=kw maxlength=150>
<SPAN class=btn_wr>
<INPUT type="submit" class=btn id=su
value="检 索" >
</SPAN>
</FORM>
</DIV>
首先判断输入框edit的内容是否为空,若非空跳转到news.php页面,且把值传给news.php中的edit2。
该怎么写。本人是PHP初学,请大哥大姐指点
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function checkSubmit() {
var kw = document.getElementById('kw').value;
if (kw.length < 1) {
alert('请输入!');
return false;
}
return true;
}
</script>
</head><body>
<div id="fm">
<form name="free" method="get" action='news.php' onsubmit="return checkSubmit();">
<input type="text" name=edit class="STYLE2" id="kw" maxlength="150">
<span class="btn_wr">
<input type="submit" class="btn" id="su" value="检 索" >
</span>
</form>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function checkSubmit() {
var kw = document.getElementById('kw').value;
if (kw.length < 1) {
alert('请输入!');
return false;
}
return true;
}
</script>
</head><body>
<div id="fm">
<form name="free" method="get" action='news.php' onsubmit="return checkSubmit();">
<input type="text" name=edit class="STYLE2" id="kw" maxlength="150">
<span class="btn_wr">
<input type="submit" class="btn" id="su" value="检 索" >
</span>
</form>
</div>
</body>
</html>
if(str){
document.action = "news.php?v="+str;
}在news.php页面,$_GET['v']就是从上一个页面传过来的值。
if(str){
document.action = "news.php?v="+escape(str);
}
因此,对于中文字符串来说,假如不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用escape。假如你的页面是GB2312或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者encodeURIComponent。在php页面用获取值urldecode($_GET['v']);
javascript : encodeURIComponent( html )
php::$html [直接获得,和urlencode得到的数据一样]
php向javascript传递敏感字符串
php:htmlspecialchars( $html )
javascript: decodeURIComponent( html )