Kan man gøre det på en anden måde? DB/ASP
Er der en bedre måde at gøre det her på?Jeg har selv programmeret dette forslag, men det virker bare ikke til det jeg skal... ØV
Prøv mit link: http://localhost/test/asptest.asp
CODE:
<%@ Language=VBScript %>
<%Option explicit
Dim oRs, conn, connect, strSQL
set conn=server.CreateObject ("adodb.connection")
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("cykeldata.mdb") & ";Persist Security Info=False"
conn.Open connect
%>
<script language="javascript">
<!--
function dept_onchange(frmSelect) {
frmSelect.submit();
}
//-->
</script>
<html>
<head>
<title>dropdowntest</title>
</head>
<body bgcolor="#ffffff" link="black">
<table width="651" border="0" cellspacing="0" cellpadding="3">
<tr>
<td valign="top" width="408">
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="80%">
<div align="left">
<form name="frmSelect" method="Post" action="asptest.asp">
<div align="left">
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><select name=hjul language=javascript onchange="return dept_onchange(frmSelect)">
<%
Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT ID_no, beskrivelse, moms, exmoms, pris FROM tblhjul ORDER BY ID_no"
oRs.Open strSQL, conn
Do while not oRs.EOF
if Request.Form("hjul") = oRs("ID_no") & oRS ("beskrivelse") & oRS ("moms") & oRS ("exmoms") & oRS ("pris") then 'if this is the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRS ("ID_no") & (" ") & oRS ("beskrivelse") & "' SELECTED>"
Response.Write oRs("ID_no") & oRS ("beskrivelse") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '"
Response.Write ("<input type=hidden name=a1 value="" ")
Response.Write oRS ("beskrivelse") & (""">")
Response.Write ("<br>")
Response.Write ("<br>")
Response.Write oRS ("beskrivelse") & ("<br>Moms: ") & oRS ("moms") & (",-<br>Ex. Moms: ") & oRS ("exmoms") & (",-<br>Pris: ") & oRS ("pris")
Response.Write (",-")
Response.Write ("<input type=hidden name=a2 value= ")
Response.Write oRS ("moms")
Response.Write (">")
Response.Write ("<input type=hidden name=a3 value= ")
Response.Write oRS ("exmoms")
Response.Write (">")
Response.Write ("<input type=hidden name=a4 value= ")
Response.Write oRS ("pris") & ("> ") & "'>"
Response.Write oRS ("beskrivelse") & (" ") & oRS ("pris") & (" ") & "</Option>"
oRs.MoveNext
end if
loop
%>
</select> <br>
1.<%=Request.Form ("hjul")%><br>
<br>
</font></div>
</form>
</div>
</td>
</tr>
</table>
<font size="2" color="#ff3300" face="Verdana, Arial, Helvetica, sans-serif"> </font></div>
<div align="left">
</div>
<div align="center">
<p></p>
</div>
</td>
<td valign="top">
<div align="center">
<img src="pics/dbpic.jpg" alt="" border="0"></div>
</td>
</tr>
</table>
</body>
</html>
CODE slut:
Mvh Ian