我在使用IE8的时候网站的搜索功能不能使用了,使用input 标签提交表单后 整个表单中的值 都是空的 根本获取不到任何值如在我的表单中存在以下input 标签 <input type="text" name="txtname" value="1" />
在使用 <input type="submit" name="sub" value="提交" /> 提交表单之后,发现所有的 表单内的值全是空的 ,txtname 的值也是空的,不知道为什么,我使用的是php语言编写的 程序这样写的if($sub){
print $txtname;
}else{
print "空";
}在IE6,7中均能实现 但是 在8版本中 却不能运行
在使用 <input type="submit" name="sub" value="提交" /> 提交表单之后,发现所有的 表单内的值全是空的 ,txtname 的值也是空的,不知道为什么,我使用的是php语言编写的 程序这样写的if($sub){
print $txtname;
}else{
print "空";
}在IE6,7中均能实现 但是 在8版本中 却不能运行
<script language="javascript" type="text/javascript" >
function chksearch1()
{
if(document.getElementById("content").value=='')
{
alert("筛选内容不能为空!");
return false;
}
}
</script>
<form name="frmsearch" method="post" action="{$shop_url}main_buyInformation.php?search=1" onSubmit="return chksearch1()">
<table width="280" height="146" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="88" align="center" class="STYLE2">筛选内容</td>
<td width="192" align="left"><input type="text" id="content" name="content" style="height:15px;"></td>
</tr>
<tr>
<td colspan="2" align="center" class="STYLE2"><table width="187" height="17" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><input type="radio" name="radtype" value="1" checked="checked"> 产品</td>
<td align="center"><input type="radio" name="radtype" value="2"> 设备</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" class="STYLE2">选择省份</td>
<td align="left"><table width="173" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="71" align="left"><select id="province" name="province" onChange="on_pro_select_change()" class="sr">
</select></td>
<td width="102" align="left"><select id="city" name="city" onChange="on_city_change()">
<option>城市</option>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" align="center" class="STYLE2"><table width="187" height="17" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right" width="45"><input type="checkbox" id="radvip" name="radvip" value="1"></td>
<td align="left" colspan="3"> 查看收费会员信息</td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td align="left"><input type="submit" name="search" value=" " class="sub1" /></td>
</tr>
</table>
</form>
php 程序如下
if($_GET['search']==1 )//使用前边的if以下程序运行,但是我定义的$condition却不能获取到静态页的任何值,不管是文本框(content),或是单选按钮(radtype),或者复选框(radvip),亦或是下拉框(province,city)全部为空,郁闷啊! 或者 if($search)--使用该if 以下内容根本不运行
{
//查找求购信息
$condition = " where ordersorts =1 and avlidtime >$timestamp ";
//首先判断查找条件
if($content!='')
$condition .= " and (keyword like'%$content%' or keyword_2 like '%$content%' or keyword_3 like '%$content%'
or keyword_4 like '%$content%' or keyword_5 like '%$content%' or title like '%$content%')";
if($radtype=='1')
$condition .=" and sorttype='产品' ";
elseif($radtype=='2')
$condition .=" and sorttype='设备' ";
if($province!='全国')
{
$provinces = deletepcz($province);
$condition .= " and province like '%$provinces%' ";
}
if($city!='城市' && $city!='全国' && $city!='0' && $province!='天津市' && $province!='北京市' && $province!='重庆市')
{
$citys = deletepcz($city);
$condition .= " and city like '%$citys%' ";
}
if($radvip)
{
//仅限收费VIP用户
$sql = "select * from $table_members where groupid =3 or groupid=7";
$query = $db->query($sql);
while($db_rec = $db->fetch_array($query))
{
$allids[] = $db_rec;
}
if(is_array($allids))
{
$ids = $comma = "";
foreach($allids as $obj)
{
$ids .= "$comma'$obj[userid]'";
$comma = ", ";
}
}
}
if($ids!='')
$condition .= " and userid in ($ids)";
//print $condition;
$query = $db->query("select count(*) from $table_buyproducts $condition");//, $table_shops s
$count=$db->result($query,0);
$perpage=30;
if ($count <= $perpage)
{
$maxpage=1;
}
else
{
$maxpage=($count - ($count % $perpage))/$perpage;
$maxpage=$maxpage+1;
}
if(!empty($page))
{
$start_limit=($page-1) * $perpage;
$startnum = ($page-1) * $perpage + 1;
$endnum = $page * $perpage;
}
else
{
$startnum = 1;
$endnum = $perpage;
$start_limit=0;
$page = 1;
}
$multipage = multi($count, $perpage, $page, "main_buyInformation.php?search=1&radtype=".$radtype);
//查询求购信息
$sql = "select * from $table_buyproducts $condition order by posttime desc LIMIT $start_limit,$perpage";
$query = $db->query($sql);
while($db_rec = $db->fetch_array($query))
{
//根据用户编号查询该用户的公司名称
$userid = $db_rec['userid'];
$db_rec['description'] = wordscut(removespace(strip_tags($db_rec['description'])),100);
$sql = "select * from $table_shops where ownerid=$userid";
$query1 = $db->query($sql);
$db_rec1 = $db->fetch_array($query1);
$db_rec['shopsname'] = strip_tags($db_rec1['shopname']);
$db_rec['shopid'] = $db_rec1['shopsid'];
$db_rec['zhishu'] = $db_rec1['zhishu'];
//查询该商品是否是VIP用户所发
$sql = "select * from $table_members where userid=$userid";
$query2 = $db->query($sql);
$db_rec2 = $db->fetch_array($query2);
$db_rec['groupid'] = $db_rec2['groupid'];
$db_rec['posttime'] = date("m/d h:i",$db_rec['posttime']);
$allsonspro[]= $db_rec;
}
include template('buyproductlist');
}
lz代码很强,你的from是post,却没有获取$_POST就进行判断……………………而是直接用$_POST的key做为变量去进行判断……………………………………………………………………………………………………………………请问你那变量的值从哪来的???
先把东西取出来再用吧,表达POST提交的都在$_POST里面,先拿出来再说数据处理的部分~
$content = $_POST['conte'];这样用过,但是 依然没值,
至于8 楼 和 9 楼说的 下部的else代码 对于这个form是用不到的它如果运行的话 就只能是 if所以else没必要写了
print $$_POST['txtname'];
}else{
print "空";
}
同时用了post 和get 朋友 建议你给一下程序~ 这样很容易出错
我之前是这样写的
action="{$shop_url}main_buyInformation.php" 但是 提交后没值,后来我添加的 ?search=1虽然 if($_GET['search']=='1') 能执行,但是还是获取不到 表单中的任何一个元素的值……to13楼:
姐姐你说浏览器的问题,请问你知道哪出问题了么
你说 CSS也会影响取值,那什么情况下 的CSS会影响取值,能举个例子么,谢谢
你 action="main_buyInformation.php" 看看
针对IE的注解css-hack可以, 但不知你的html会不会设置成这样。
对于你说的如上方法是必须的 因为 我的 html页面是静态页(转静态了)并且 不和php 同文件夹下,所以我必须使用绝对路径,假如我的域名为 http://www.aa.com 则 {$shop_url} = http://www.aa.com/
那么{$shop_url}main_buyInformation.php = http://www.aa.com/main_buyInformation.php
所以我觉得问题不出在这
我不太明白你的意思,能说的详细点么汗,竟然写错 楼层了 ⊙﹏⊙b
我用ie8测试了一下你的html代码,一切正常,建议你检查一下你其它html部份,包括doctype头, 还有php代码,我的测试代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- 添加了doctype头,改了action,其它没变,测试正常 --><form name="frmsearch" method="post" action="" onSubmit="return chksearch1()">
<table width="280" height="146" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="88" align="center" class="STYLE2">筛选内容</td>
<td width="192" align="left"><input type="text" id="content" name="content" style="height:15px;"></td>
</tr>
<tr>
<td colspan="2" align="center" class="STYLE2"><table width="187" height="17" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><input type="radio" name="radtype" value="1" checked="checked"> 产品</td>
<td align="center"><input type="radio" name="radtype" value="2"> 设备</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" class="STYLE2">选择省份</td>
<td align="left"><table width="173" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="71" align="left"><select id="province" name="province" onChange="on_pro_select_change()" class="sr">
</select></td>
<td width="102" align="left"><select id="city" name="city" onChange="on_city_change()">
<option>城市</option>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" align="center" class="STYLE2"><table width="187" height="17" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right" width="45"><input type="checkbox" id="radvip" name="radvip" value="1"></td>
<td align="left" colspan="3"> 查看收费会员信息</td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td align="left"><input type="submit" name="search" value=" " class="sub1" /></td>
</tr>
</table>
</form><script language="javascript" type="text/javascript" >
function chksearch1()
{
if(document.getElementById("content").value=='')
{
alert("筛选内容不能为空!");
return false;
}
}
</script>
<?php print_r($_POST); //收到值 ?>