Tjo!Spara sorteringen.
har en kod här som funkar bra, men den gör inte riktigt så som jag vill, kan någon hjälpa mig så att den sparar själva sorteringen då jag klickar på exit knappen, eller om man lägger till en spara knapp.
/Tommy
<!--header -->
<html>
<head>
<title>sortera</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!-- main content -->
<table width="760" border="0" cellspacing="5" cellpadding="5" align="center">
<tr valign="top">
<td height="350">
<span id="Layer1" style="position:absolute; width:650; height:350px; z-index:1; overflow: auto; left: 0px">
<%'##############################################
'get all records from the table of your choice
dim oConn, rsUser, sSQL
Set oConn = Server.Createobject("ADODB.Connection")
oConn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("../kontakt.mdb")
sSQL = "Select * From kontakt "
Set rsUser = Server.CreateObject("ADODB.Recordset")
rsUser.Open sSQL, oConn, 3, 3
If Not (rsUser.EOF And Not rsUser.BOF) Then
'can now start displaying the current set of records
i = 1%>
<table width="100%" border="0">
<tr>
<td class="normal" colspan="5" height="1" align="right"><img src="images/spacer_grey.gif" width="100%" height="1"></td>
</tr>
<tr bgcolor="#eaeaea">
<td class="normal" width="30"> <b>Field1</b></td>
<td class="normal" width="*."> <b>Field2</b></td>
<td class="normal" width="50"> <b>Field3</b></td>
<td class="normal" width="50"> <b>Field4</b></td>
<td class="normal" width="50"> <b>Field5</b></td>
</tr>
<tr>
<td class="normal" colspan="5" height="1"><img src="images/spacer_grey.gif" width="100%" height="1"></td>
</tr>
<%'loop thorugh the records
While Not rsUser.EOF%>
<tr bgcolor="#ffffff" id="row_<%=i%>" onclick="changeColor(<%=i%>)">
<td class="normal" width="30" id="row_<%=i%>col_1"> <%=rsUser(0)%></td>
<td class="normal" width="*." id="row_<%=i%>col_2"> <%=rsUser(1)%></td>
<td class="normal" width="50" id="row_<%=i%>col_3"> <%=rsUser(2)%></td>
<td class="normal" width="50" id="row_<%=i%>col_4"> <%=rsUser(3)%></td>
<td class="normal" width="50" id="row_<%=i%>col_5"> <%=rsUser(4)%></td>
</tr>
<%i = i + 1
rsUser.MoveNext
Wend%>
<tr>
<td class="normal" colspan="5"> </td>
</tr>
<tr>
<td colspan="5" class="Normal" align="right">
<input type="button" name="btnExit" value="exit" class="normal" onclick="window.close();">
</td>
</tr>
</table>
<%Else%>
<table width="100%" border="0">
<tr>
<td class="normal" colspan="5" height="1" align="right"><img src="images/spacer_grey.gif" width="100%" height="1"></td>
</tr>
<tr bgcolor="#eaeaea">
<td class="normal" width="30"> <b>Field1</b></td>
<td class="normal" width="*."> <b>Field2</b></td>
<td class="normal" width="50"> <b>Field3</b></td>
<td class="normal" width="50"> <b>Field4</b></td>
<td class="normal" width="50"> <b>Field5</b></td>
</tr>
<tr>
<td class="normal" colspan="5" height="1"><img src="images/spacer_grey.gif" width="100%" height="1"></td>
</tr>
<tr>
<td colspan="5" class="Normal">0 records found</td>
</tr>
<tr>
<td colspan="5" class="Normal"> </td>
</tr>
<tr>
<td colspan="5" class="Normal" align="right">
<input type="button" name="btnExit" value="exit" class="normal" onclick="window.close();">
</td>
</tr>
</table>
<%End If
rsUser.Close : Set rsUser = Nothing%>
</span>
</form>
<!-- span to put the up and down buttons in -->
<span id="Layer2" style="position:absolute; width:90; height:350px; z-index:1; overflow: auto; left: 665px">
<table width="70">
<tr>
<td><input type="button" value="Move Up" onClick="moveUp();" style="width:70" class="normal"></td>
</tr>
<tr>
<td><input type="button" value="Move Down" onClick="moveDown();" style="width:70" class="normal"></td>
</tr>
</table>
</span>
</td>
</tr>
</table>
<%'clean up
oConn.Close : Set oConn = nothing%>
</body>
</html>
<script language="javascript">
var gRow = "";
function changeColor(index){
//highlight the selected row
var sElement
sElement = document.all['row_' + index];
if (sElement.style.backgroundColor=="#ffffff" || sElement.style.backgroundColor==""){
sElement.style.backgroundColor="#ff0000";
if (gRow != "" && gRow != index) {
sElement = document.all['row_' + gRow];
sElement.style.backgroundColor="#ffffff";
}
gRow = index
} else {
sElement.style.backgroundColor="#ffffff";
}
}
function moveUp(){
//move the selectd row up one place
var sElement
var sNewElement
var totalrecords = <%=i%>
if (gRow == "") {
alert ("Please select a row to move up.");
} else {
if (totalrecords > 1){
// get the current ro from global variable
if (gRow > 1) {
var gNewRow = gRow - 1 //moving up
for (var i = 1; i < 6; i++) {
//loop through the columns
sElement = document.all['row_' + gRow + 'col_' + i]
sNewElement = document.all['row_' + gNewRow + 'col_' + i]
var sValue = sElement.innerHTML
var sNewValue = sNewElement.innerHTML
//set the new row and change the old one
sElement.innerHTML = sNewValue
sNewElement.innerHTML = sValue
}
sElement = document.all['row_' + gRow];
sElement.style.backgroundColor="#ffffff";
//set the new row to be highlighted
sElement = document.all['row_' + gNewRow];
sElement.style.backgroundColor="#ff0000";
gRow = gNewRow
}
}
}
}
function moveDown(){
//move the selectd row up one place
var sElement
var sNewElement
var totalrecords = <%=i%>
if (gRow == "") {
alert ("Please select a row to move down.");
} else {
if (totalrecords > 1){
// get the current ro from global variable
if (gRow < totalrecords - 1) {
var gNewRow = gRow + 1 //moving up
for (var i = 1; i < 6; i++) {
//loop through the columns
sElement = document.all['row_' + gRow + 'col_' + i]
sNewElement = document.all['row_' + gNewRow + 'col_' + i]
var sValue = sElement.innerHTML
var sNewValue = sNewElement.innerHTML
//set the new row and change the old one
sElement.innerHTML = sNewValue
sNewElement.innerHTML = sValue
}
sElement = document.all['row_' + gRow];
sElement.style.backgroundColor="#ffffff";
//set the new row to be highlighted
sElement = document.all['row_' + gNewRow];
sElement.style.backgroundColor="#ff0000";
gRow = gNewRow
}
}
}
}
</script>