Rokering via Select menu
Hejsa.. Jeg skal med denne klumset kode, kunne via en form rokere et indlægs position.. Fx via en dropdown menu.Anyone who can help?
<%
sub rykposition(newpos,oldpos)
if newpos < oldpos then
dim sql1
dim strConn, strconn2, strconn1
dim x, sql, sql2
Set strconn1 =Server.CreateObject("ADODB.Connection")
strConn1.open="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/wjt.mdb")
sql1= "UPDATE staff SET position = 0 where position="&oldpos&""
strConn1.Execute (sql1)
strconn1.close
for x=oldpos-1 to newpos step -1
Set strconn =Server.CreateObject("ADODB.Connection")
strConn.open="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/wjt.mdb")
sql = "UPDATE staff SET position = "&x&" + 1 where position = "&x&""
response.write sql
strConn.Execute (sql)
strconn.close
next
Set strconn2 =Server.CreateObject("ADODB.Connection")
strConn2.open="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/wjt.mdb")
sql2= "UPDATE staff SET position = "&newpos&" where position=0"
strConn2.Execute (sql2)
strconn2.close
else
dim sql3
dim strConn3, strconn4, strconn5
dim xy, sql4, sql5
Set strconn3 =Server.CreateObject("ADODB.Connection")
strConn3.open="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/wjt.mdb")
sql3= "UPDATE staff SET position = 0 where position="&oldpos&""
strConn3.Execute (sql3)
strconn3.close
for x=oldpos+1 to newpos
Set strconn4 =Server.CreateObject("ADODB.Connection")
strConn4.open="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/wjt.mdb")
sql4 = "UPDATE staff SET position = "&x&" - 1 where position = "&x&""
response.write sql4
strConn4.Execute (sql4)
strconn4.close
next
Set strconn5 =Server.CreateObject("ADODB.Connection")
strConn5.open="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/wjt.mdb")
sql5= "UPDATE staff SET position = "&newpos&" where position=0"
strConn5.Execute (sql5)
strconn5.close
end if
end sub
%>
call rykposition(5,10)
<%
call rykposition(5,10)
%>