Hello all, Thanx for the inputs. But I think I should give u this
code, and the picture will be much more clear. First of all I created
this site in Dreamweaver and I deleted so many lines which I thought
wont do any good to solve the things I mentioned.
When I change the drop-down 'cboAbteilungID', it should filter the
drop-down 'cboArbeitsplatzID'. I tried to keep the selected value in
'cboAbteilungID', but its not working!
---------------------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' *** Edit Operations: declare variables
' *** DELETED variables declared by Dreamweaver
' Get value from select box
iAbteilungID = Trim(Request.QueryString("cboAbteilungID"))
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
' ******* DELETED *******
%>
<%
Dim rsPersonSoftware
Dim rsPersonSoftware_numRows
Set rsPersonSoftware = Server.CreateObject("ADODB.Recordset")
rsPersonSoftware.ActiveConnection = MM_userverwaltung_STRING
rsPersonSoftware.Source = "SELECT tblPersonID, tblSoftwareID FROM
dbo.tblPersonSoftware"
rsPersonSoftware.CursorType = 2
rsPersonSoftware.CursorLocation = 2
rsPersonSoftware.LockType = 3
rsPersonSoftware.Open()
rsPersonSoftware_numRows = 0
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
' **** DELETED *****
MM_editQuery = "SET NOCOUNT ON; insert into " & MM_editTable & " ("
& MM_tableValues & ") values (" & MM_dbValues & ");"&_
"SELECT SCOPE_IDENTITY() AS LastPersonID;"
If (Not MM_abortEdit) Then
' execute the insert
Dim iLastPersonID
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
'Get the last PersonID added, and insert datas
MM_editCmd.CommandType = 1 'adCmdText
Set rsPID = MM_editCmd.Execute
iLastPersonID = rsPID.Fields("LastPersonID").Value
' insert checked checkboxes values to BD
For i = 1 to 100 ' need to put in an upperbound that corresponds to
the total recordset count
If Request.Form("chkSoftware" & i) Then
'strSql1 = "INSERT into tblPersonSoftware (tblPersonID,
tblSoftwareID) values (" & iLastPersonID & ", " & i & ")"
rsPersonSoftware.Addnew
rsPersonSoftware("tblSoftwareID") = i
rsPersonSoftware("tblPersonID") = iLastPersonID
rsPersonSoftware.Update
End If
Next
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = Nothing
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim PersonStatus
Dim PersonStatus_numRows
Set PersonStatus = Server.CreateObject("ADODB.Recordset")
PersonStatus.ActiveConnection = MM_userverwaltung_STRING
PersonStatus.Source = "SELECT StatusID, Status FROM dbo.tblStatus
ORDER BY Status ASC"
PersonStatus.CursorType = 0
PersonStatus.CursorLocation = 2
PersonStatus.LockType = 1
PersonStatus.Open()
PersonStatus_numRows = 0
%>
<%
Dim Arbeitsplatz
Dim Arbeitsplatz_numRows
Set Arbeitsplatz = Server.CreateObject("ADODB.Recordset")
Arbeitsplatz.ActiveConnection = MM_userverwaltung_STRING
Arbeitsplatz.Source = "SELECT ArbeitsplaetzeID, PCNummer FROM
dbo.tblArbeitsplatz WHERE tblAbteilungID='" & iAbteilungID & "'
ORDER BY PCNummer ASC"
Arbeitsplatz.CursorType = 0
Arbeitsplatz.CursorLocation = 2
Arbeitsplatz.LockType = 1
Arbeitsplatz.Open()
Arbeitsplatz_numRows = 0
%>
<%
Dim Abteilungen
Dim Abteilungen_numRows
Set Abteilungen = Server.CreateObject("ADODB.Recordset")
Abteilungen.ActiveConnection = MM_userverwaltung_STRING
Abteilungen.Source = "SELECT AbteilungID, Abteilung, Standort,
tblStandortID FROM dbo.Abteilungen ORDER BY Abteilung ASC, Standort
ASC "
Abteilungen.CursorType = 0
Abteilungen.CursorLocation = 2
Abteilungen.LockType = 1
Abteilungen.Open()
Abteilungen_numRows = 0
%>
<%
Dim rsSoftware
Dim rsSoftware_numRows
Set rsSoftware = Server.CreateObject("ADODB.Recordset")
rsSoftware.ActiveConnection = MM_userverwaltung_STRING
rsSoftware.Source = "SELECT SoftwareID, SoftwareName FROM
dbo.tblSoftware ORDER BY SoftwareName ASC"
rsSoftware.CursorType = 0
rsSoftware.CursorLocation = 2
rsSoftware.LockType = 1
rsSoftware.Open()
rsSoftware_numRows = 0
%>
<%
Dim rsPerson
Dim rsPerson_numRows
Set rsPerson = Server.CreateObject("ADODB.Recordset")
rsPerson.ActiveConnection = MM_userverwaltung_STRING
rsPerson.Source = "SELECT PersonID FROM dbo.tblPersonen"
rsPerson.CursorType = 0
rsPerson.CursorLocation = 2
rsPerson.LockType = 1
rsPerson.Open()
rsPerson_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsSoftware_numRows = rsSoftware_numRows + Repeat1__numRows
%>
<html>
<head>
<title>New Personen - Userverwaltung</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
** deleted the code for form validation
//-->
</script>
</head>
<body>
<form action="<%=MM_editAction%>" method="POST" name="frmNewPerson"
onSubmit="MM_validateForm('Vorname','','R','Name','','R','Email','','NisEmail');return
document.MM_returnValue">
<table>
<tr valign="baseline">
<td nowrap align="right">Name:</td>
<td> <input type="text" name="Name" value="" size="32"> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Zusatzsoftware:</td>
<td> <%
While ((Repeat1__numRows <> 0) AND (NOT rsSoftware.EOF))
%>
<input type="checkbox"
name="chkSoftware<%=(rsSoftware.Fields.Item("SoftwareID").Value)%>"
value="<%=(rsSoftware.Fields.Item("SoftwareID").Value)%>">
<%=(rsSoftware.Fields.Item("SoftwareName").Value)%>
<% Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsSoftware.MoveNext()
Wend
%>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Status:</td>
<td> <select name="cboStatusID">
<%
While (NOT PersonStatus.EOF)
%>
<option value="<%=(PersonStatus.Fields.Item("StatusID").Value)%>"
<%If (Not isNull((PersonStatus_first))) Then If
(CStr(PersonStatus.Fields.Item("StatusID").Value) =
CStr((PersonStatus_first))) Then Response.Write("SELECTED") :
Response.Write("")%>
<%=(PersonStatus.Fields.Item("Status").Value)%></option>
<%
PersonStatus.MoveNext()
Wend
If (PersonStatus.CursorType > 0) Then
PersonStatus.MoveFirst
Else
PersonStatus.Requery
End If
%>
</select> </td>
<tr valign="baseline">
<td nowrap align="right">Abteilung:</td>
<td> <select name="cboAbteilungID"
onChange="window.location='<%=Request.Servervariables("Script_Name")%>?cboAbteilungID='+this.value;">
<%
While (NOT Abteilungen.EOF)
%>
<option <% If Abteilungen("AbteilungID") =
Request.QueryString("cboAbteilungID") Then Response.Write("selected")
End If %> value="<%=(Abteilungen.Fields.Item("AbteilungID").Value)%>">
<%=(Abteilungen.Fields.Item("Abteilung").Value)%>,
<%=(Abteilungen.Fields.Item("Standort").Value)%>
</option>
<%
Abteilungen.MoveNext()
Wend
If (Abteilungen.CursorType > 0) Then
Abteilungen.MoveFirst
Else
Abteilungen.Requery
End If
%>
</select> </td>
</tr>
</tr>
<tr valign="baseline">
<td nowrap align="right">PC-Nummer:</td>
<td> <select name="cboArbeitsplatzID">
<%
If Arbeitsplatz.EOF Then
Response.Write("<option>(Kein PC zugeordnet)</option>")
Else
While (NOT Arbeitsplatz.EOF)
%>
<option value="<%=(Arbeitsplatz.Fields.Item("ArbeitsplaetzeID").Value)%>"
<%If (Not isNull((PersonStatus_first))) Then If
(CStr(Arbeitsplatz.Fields.Item("ArbeitsplaetzeID").Value) =
CStr((PersonStatus_first))) Then Response.Write("SELECTED") :
Response.Write("")%>
<%=(Arbeitsplatz.Fields.Item("PCNummer").Value)%></option>
<%
Arbeitsplatz.MoveNext()
Wend
If (Arbeitsplatz.CursorType > 0) Then
Arbeitsplatz.MoveFirst
Else
Arbeitsplatz.Requery
End If
End If
%>
</select> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> <input type="submit" value="Datensatz einfügen"> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="frmNewPerson">
</form>
PersonStatus.Close()
Set PersonStatus = Nothing
%>
<%
Arbeitsplatz.Close()
Set Arbeitsplatz = Nothing
%>
<%
Abteilungen.Close()
Set Abteilungen = Nothing
%>
<%
rsSoftware.Close()
Set rsSoftware = Nothing
%>
<%
rsPerson.Close()
Set rsPerson = Nothing
%>