Home > Backend Development > PHP Tutorial > html标签select的问题 数据查询结果显示在下拉菜单中

html标签select的问题 数据查询结果显示在下拉菜单中

WBOY
Release: 2016-06-23 14:02:22
Original
1237 people have browsed it

html select下拉菜单中有自己手动添加进来的菜单,比如


现在我从数据库中查询的结果是2,如何让页面显示的时候,下拉菜单自动锁定在“价值2”呢?


回复讨论(解决方案)


$value = 2;
echo "<script>document.getElementById('name').value = $value</script>";


$value = 2;
echo "<script>docu…… <br /> 太好了,问题解决 </script>

<select name="sex" id="sex"/><option value=""></option><option value="男">男</option><option value="女">女</option></select>        <php>        	$value=$list['sex'];            echo "<script>document.getElementById('sex').value =$value</script>";        </php>
Copy after login


这个地方有什么错误吗?老是不行

<select name="sex" id="sex"><option value=""></option><option value="男">男</option><option value="女">女</option></select><?php$value=$list['sex'];echo "<script>document.getElementById('sex').value ='$value'</script>";?>
Copy after login

本帖最后由 xuzuning 于 2013-03-09 11:51:14 编辑
            PHP code?12345

有引号括起的是串,没有引号就成了变量了(js)

原来如此,对js这部分了解还真的不多。谢谢指教

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template