Search into a database using a form with various options
I have an .asp page and I am using VBscript. basically I have a database with country, partner type and phone columns. I know how to load these into a recordset and display them into an .asp page.
I am using a dropdown for Partner Type and Country, and I am using a label for the phone.
Now what I a开发者_运维百科m trying to do is that when a user selects a partner type, the information related to that partner type will show. I really dont know from where to start :/ I am not askign for someone to do all this for me, but i need some tips or maybe online tutorials. Thanks
As you pointed out it is not easy to answer because the question is so wide. I'll try to make a simplified code example and then you surely can fill in the remaining bits.
<%
dim country
dim partnerType
dim phone
country = request("country")
partnerType = request("partnerType")
dim phone = request("phone")
'Get more information from database
Set objConnect = Server.CreateObject("ADODB.Connection")
objConnect.ConnectionTimeout = 580
objConnect.Open "myConnectionString"
set objRS = Server.CreateObject("ADODB.Recordset")
objRS .Open "select * from yourTable", objConnect, , , adCmdText
while not objRS.EOF
response.write "found record in database"
loop
%>
<html>
<body>
<form id="myForm">
<label>Country</label><select name="country"><option value="se">Sweden</option></select>
<label>PartnerType</label><select name="partnerType" onChange="PtypeChanged();"><option value="1">Reseller</option><option value="2">International</option></select>
<input type="text" name="phone" value="" />
</form>
<script>
function PtypeChanged(){
document.getElementById("myForm").submit();
}
</script>
</body>
</html>
sounds like you're looking to create dependent dropdown lists. There's an example with a demo here:
http://www.aspkey.net/aspkey/_articles/asp/showarticle.asp?id=100
精彩评论