无法获取select option的值

littlebirds 2011-03-28 03:59:44

for($i = 1;$i<3;$i++)
{
$select[$i] = $_GET['sel'.$i];
}

$flag =1;
for($i = 1;$i<3;$i++)
{
if($select[$i] == 'ALL'|| $select[$i] ==''){
$str .= '';
}
else
{
if($flag == 1)
{
$str .= " Where ";
$str .= $tt_selname[$i] ."= '".$select[$i]."'";
$index = array_search($select[$i],$tt_option[$i]);
$is_selected[$i][$index] = 'selected';

$flag --;
}
else
{
$str .= ' and '.$tt_selname[$i]."= '".$select[$i]."'";
$index = array_search($select[$i],$tt_option[$i]);
$is_selected[$i][$index] = 'selected';
}
}
}


<script>
function setselstate(step_value)
{
document.getElementById('sel2').options[0].selected = true;


if (step_value != 'ALL')
{
document.getElementById('sel2').disabled = false;
}
else
{
document.getElementById('sel2').disabled = true;
}
}


function setselstate2(step_value)
{
if (step_value != 'ALL')
{
document.getElementById('sel2').disabled = false;
}
else
{
document.getElementById('sel2').disabled = true;
}
}
</script>


<form name="frm1" method="get" action="budget_control.php?action=do">
<table >
<tr>
<td align="right"><b>项目</b> </td>
<td><select name="sel1" id="sel1" onchange="setselstate(this.value);">
<option value="ALL">ALL</option>
<?php
for($i=0;$i<count($tt_option[1]);$i++)
echo '<option value="'.$tt_option[1][$i].'" '.$is_selected[1][$i].'>'.$tt_option[1][$i].'</option>';
?>
</select>
</td>


数据库部分字段:

ID
Num(序号)
project(项目)


现在项目选项(project)里无法获取数据库中project字段的值,请问是什么原因?


...全文
288 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
littlebirds 2011-03-29
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hnxxwyq 的回复:]

HTML code


<form name="frm1" method="get" action="budget_control.php?action=do">
<table >
<tr>
<td align="right"><b>项目</b> </td>
<td><select name="sel1" id="sel1" onchange……
[/Quote]
$tt_option[1][$i]是一个自定义option的项。主要功能是一个2级的查询。
lazyboy_wu 2011-03-28
  • 打赏
  • 举报
回复


<form name="frm1" method="get" action="budget_control.php?action=do">
<table >
<tr>
<td align="right"><b>项目</b> </td>
<td><select name="sel1" id="sel1" onchange="setselstate(this.value);">
<option value="ALL">ALL</option>
<?php
for($i=0;$i<count($tt_option[1]);$i++)
// 这里$tt_option[1][$i]的内容有特殊编码吗?例如引号之类的,建议value用数字id
echo '<option value="'.$tt_option[1][$i].'" '.$is_selected[1][$i].'>'.$tt_option[1][$i].'</option>';
?>
</select>
</td>


ImN1 2011-03-28
  • 打赏
  • 举报
回复
sorry! 眼花,$i<3看成$i<=3了
ImN1 2011-03-28
  • 打赏
  • 举报
回复
这个……php按js来写?

好混乱,php里面有sel1/sel2/sel3
但html里面只有sel1啊……二级下拉菜单?

第二个问题,你的下拉菜单不提交就想执行php么?

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧