从数据库中检索数据并使用VBSCRIPT将其传递给html页面 [英] retrieving data from database and pass it to html page using VBSCRIPT

查看:81
本文介绍了从数据库中检索数据并使用VBSCRIPT将其传递给html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从asp页面上的数据库(MS访问)中检索值并将该值赋给html中的select标签?



i想给我的html页面的粗体部分赋值





how can i retrieve value from database (MS access) on asp page and give that value to the select tag in html??

i want to give values to the bolded part which is my html page


<html>
<body>


<form action="select.asp" method="post">
<select name="brd"  >
<option>select one</option>
<option value="one">one</option>
<option value="two">two</option>
</select>
<input type="submit" >
</form>
</body>
</html>

推荐答案

自从我做了任何经典ASP并且我没有环境来测试这个设置已经有很长一段时间了,但我认为我的语法正确。这应该足以让你前进。此文件需要具有ASP扩展名。

It's been a long time since I did any "classic" ASP and I don't have the environment to test this set up, but I think I have the correct syntax. This should be enough to get you going. This file does need to have an ASP extension.
<%@ language="VBSCRIPT" %>
<html>
<body>
<%
    Set con = Server.CreateObject("ADODB.Connection")
    con.Open "MyAccessDB.MDB"
    Set rs = con.Execute("SELECT MyOption FROM MyOptionsLookupTable")
%> 
 
<form action="select.asp" method="post">
<select name="brd">
<option>select one</option>
<% While Not rs.EOF %>
<option value=<% """ & rs("MyOption") & """ %>><% rs("MyOption") %></option>
<% 
    rs.MoveNext
    Wend
    rs.Close
    con.Close 
 %>
</select>
<input type="submit">
</input></form>
</body>
</html>


这篇关于从数据库中检索数据并使用VBSCRIPT将其传递给html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆