好吧我已经得到了这么远的你的美妙帮助,只是试图找出我要去哪里错了吗?动态下拉 - 用于表格创建的用户选择。可能吗?
<script>
function disp_text()
{
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
location.href="By_regions_report2.php?selected_text=" + selected_text; //loading a seperate php page to catch result
alert(selected_text);
}
</script>
<?php
$dropdown_sql="SELECT DISTINCT `2010 RSG Code` AS codes FROM locations";
$dropdown_result=mysql_query($dropdown_sql);
$options="";
while ($row=mysql_fetch_array($dropdown_result)) {
$codes=$row["codes"];
$options.="<OPTION VALUE=\"codes\">$codes</option>";
}
?>
<form NAME="myform">
<SELECT NAME="mylist" onchange="disp_text()">
<OPTION VALUE=0>Select a region
<?php echo $options ?>
</SELECT>
</form>
这是第二个PHP文件:
<?php
$selectedCode = $_GET[selected_text];
?>
未定义的常量selected_text的得到错误使用 - 假设时的onchange()函数被调用 'selected_text'
编辑: 是有没有办法使用新变量自动重新加载原始页面?
哦我错过了''选定的文本'' – user1287030 2012-03-23 01:05:09
尝试类似于什么我刚刚编辑到我的答案:) – Daan 2012-03-23 07:01:06