I don't see any sql insert code in your extract. All I see is the code
for displaying the data. I searched for "Insert", "AddNew" and "Update".
Are you sure the insert isn't happening on the page to which you submit
this form?
>how would
one get the text from the textarea into a variable without
"refreshing" the page? It is static on the screen while writing in
text in the textbox, it wont get into a variable by simple writin the
text(?) Or would one use some kind og afterupdate "behaviour" on the
textarea for putting the text into a variable on the page and thus
getting the text into each record?
Now we are getting into client-side code which is out of scope for this
group: ASP is server-side code. When you start talking about
afterupdate, or any other event that takes place on the client, then you
are no longer in the ASP "world". Further questions about this should go
to a client-side scripting group such as
microsoft.public.scripting.jscript.
Here is a simple example of what you seem to want (note: you can save
this in a .htm page and it will work, which reinforces the point that
this is no longer about asp):
<html>
<head>
<script type="text/javascript">
var EnteredText
function handleChange(obj)
{
EnteredText=obj.value;
alert(EnteredText);
}
</script>
</head>
<body>
<textarea name="txt_egen_fakturatext" cols="60" rows="2"
onchange="handleChange(this);">
</textarea>
</body>
</html>
Run the page, type in some text and press tab.
<snip>
I'm not going for some client side scripts, I was just thinking out loud how
it could be possible inserting the text from a textarea into a variable,
textarea being on the same page as the variable. I probably understood you
wrong as I thought you made it clear that there couldn't be any problem
getting the text from a textarea into a variable from one and same page,
despite the posts in the dmxzone njewsgroup.
I don't think your javascript example would work anyway in this case.
Nothing serverside (variable) is refreshed.
Here's the code including the insert code, sorry, I left it out by mistake.
And here's a screendump of the page with the list and the textarea (the
values going into the table are in hiddenfields
http://www.comtech.fi/filer/example.gif)
Jen.
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <"") Then
MM_editAction = MM_editAction & "?" &
Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
Dim rs_fakturera
Dim rs_fakturera_numRows
Set rs_fakturera = Server.CreateObject("ADODB.Recordset")
rs_fakturera.ActiveConnection = MM_conn_heinonen_STRING
rs_fakturera.Source = "SELECT hyresgast.*, bostad.* FROM bostad INNER JOIN
hyresgast ON bostad.bostads_id = hyresgast.Hyresbostad WHERE
skall_faktureras = true ORDER BY Efternamn"
rs_fakturera.CursorType = 2
rs_fakturera.CursorLocation = 2
rs_fakturera.LockType = 1
rs_fakturera.Open()
rs_fakturera_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rs_fakturera_numRows = rs_fakturera_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats
variables
Dim rs_fakturera_total
Dim rs_fakturera_first
Dim rs_fakturera_last
' set the record count
rs_fakturera_total = rs_fakturera.RecordCount
' set the number of rows displayed on this page
If (rs_fakturera_numRows < 0) Then
rs_fakturera_numRows = rs_fakturera_total
Elseif (rs_fakturera_numRows = 0) Then
rs_fakturera_numRows = 1
End If
' set the first and last displayed record
rs_fakturera_first = 1
rs_fakturera_last = rs_fakturera_first + rs_fakturera_numRows - 1
' if we have the correct record count, check the other stats
If (rs_fakturera_total <-1) Then
If (rs_fakturera_first rs_fakturera_total) Then
rs_fakturera_first = rs_fakturera_total
End If
If (rs_fakturera_last rs_fakturera_total) Then
rs_fakturera_last = rs_fakturera_total
End If
If (rs_fakturera_numRows rs_fakturera_total) Then
rs_fakturera_numRows = rs_fakturera_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count
them
If (rs_fakturera_total = -1) Then
' count the total records by iterating through the recordset
rs_fakturera_total=0
While (Not rs_fakturera.EOF)
rs_fakturera_total = rs_fakturera_total + 1
rs_fakturera.MoveNext
Wend
' reset the cursor to the beginning
If (rs_fakturera.CursorType 0) Then
rs_fakturera.MoveFirst
Else
rs_fakturera.Requery
End If
' set the number of rows displayed on this page
If (rs_fakturera_numRows < 0 Or rs_fakturera_numRows rs_fakturera_total)
Then
rs_fakturera_numRows = rs_fakturera_total
End If
' set the first and last displayed record
rs_fakturera_first = 1
rs_fakturera_last = rs_fakturera_first + rs_fakturera_numRows - 1
If (rs_fakturera_first rs_fakturera_total) Then
rs_fakturera_first = rs_fakturera_total
End If
If (rs_fakturera_last rs_fakturera_total) Then
rs_fakturera_last = rs_fakturera_total
End If
End If
%>
<%
' *** FX Insert Multiple Records SP in form_fakturera
If (rs_fakturera_first <"") Then ins_rs_fakturera = rs_fakturera_first-1
Else ins_rs_fakturera = 0 End If ' counter
If (cStr(Request.Form("Submit")) <"") Then
FX_sqlerror = ""
FX_insredir = "fakturalist.asp"
FX_fields =
Array("txt_egen_fakturatext","hiddenField_daum","h iddenField_manad_ar","hiddenField_efternamn","hidd enField_fornamn","hiddenField_kund_id","hiddenFiel d_hyresbostad","hiddenField_bostadsnamn","hiddenFi eld_naradress","hiddenField_telefon","hiddenField_ fakturatext","hiddenField_manadshyra","hiddenField _finsk","hiddenField_postnr","hiddenField_postadre ss","hiddenField_betalningstid","hiddenField_moms" ,"hiddenField_betald")
FX_altv = false
tmp = "ADODB.Command"
Set insert_Multi = Server.CreateObject(tmp)
insert_Multi.ActiveConnection = MM_conn_heinonen_STRING
For N = ins_rs_fakturera+1 To rs_fakturera_total
found = false
For i = 0 To UBound(FX_fields)
If (cStr(Request.Form(FX_fields(i)&N)) <"" Or FX_altv = true) Then
found = true
Exit For
End If
Next
If (found = true) Then
If (Request.Form("txt_egen_fakturatext"&N) <"") Then s1 =
Replace(Request.Form("txt_egen_fakturatext"&N),"'" ,"''") Else s1 = "" End If
If (Request.Form("hiddenField_daum"&N) <"") Then s2 =
Replace(Request.Form("hiddenField_daum"&N),"'","'' ") Else s2 = "" End If
If (Request.Form("hiddenField_manad_ar"&N) <"") Then s3 =
Replace(Request.Form("hiddenField_manad_ar"&N),"'" ,"''") Else s3 = "" End If
If (Request.Form("hiddenField_efternamn"&N) <"") Then s4 =
Replace(Request.Form("hiddenField_efternamn"&N),"' ","''") Else s4 = "" End
If
If (Request.Form("hiddenField_fornamn"&N) <"") Then s5 =
Replace(Request.Form("hiddenField_fornamn"&N),"'", "''") Else s5 = "" End If
If (Request.Form("hiddenField_kund_id"&N) <"") Then s6 =
Replace(Request.Form("hiddenField_kund_id"&N),"'", "''") Else s6 = "0" End If
If (Request.Form("hiddenField_hyresbostad"&N) <"") Then s7 =
Replace(Request.Form("hiddenField_hyresbostad"&N), "'","''") Else s7 = "0"
End If
If (Request.Form("hiddenField_bostadsnamn"&N) <"") Then s8 =
Replace(Request.Form("hiddenField_bostadsnamn"&N), "'","''") Else s8 = "" End
If
If (Request.Form("hiddenField_naradress"&N) <"") Then s9 =
Replace(Request.Form("hiddenField_naradress"&N),"' ","''") Else s9 = "" End
If
If (Request.Form("hiddenField_telefon"&N) <"") Then s10 =
Replace(Request.Form("hiddenField_telefon"&N),"'", "''") Else s10 = "" End If
If (Request.Form("hiddenField_fakturatext"&N) <"") Then s11 =
Replace(Request.Form("hiddenField_fakturatext"&N), "'","''") Else s11 = ""
End If
If (Request.Form("hiddenField_manadshyra"&N) <"") Then s12 =
Replace(Request.Form("hiddenField_manadshyra"&N)," '","''") Else s12 = "" End
If
If (Request.Form("hiddenField_finsk"&N) <"") Then s13 =
Replace(Request.Form("hiddenField_finsk"&N),"'","' '") Else s13 = "" End If
If (Request.Form("hiddenField_postnr"&N) <"") Then s14 =
Replace(Request.Form("hiddenField_postnr"&N),"'"," ''") Else s14 = "" End If
If (Request.Form("hiddenField_postadress"&N) <"") Then s15 =
Replace(Request.Form("hiddenField_postadress"&N)," '","''") Else s15 = "" End
If
If (Request.Form("hiddenField_betalningstid"&N) <"") Then s16 =
Replace(Request.Form("hiddenField_betalningstid"&N ),"'","''") Else s16 = ""
End If
If (Request.Form("hiddenField_moms"&N) <"") Then s17 =
Replace(Request.Form("hiddenField_moms"&N),"'","'' ") Else s17 = "0" End If
If (Request.Form("hiddenField_betald"&N) <"") Then s18 =
Replace(Request.Form("hiddenField_betald"&N),"'"," ''") Else s18 = "0" End If
On Error Resume Next
insert_Multi.CommandText = "INSERT INTO faktura (egen_text, datum,
manad_ar, efternamn, fornamn, Kund_ID, Hyresobjekt_id, hyresbostad,
naradress, telefon, text_pa_faktura, manadshyra, finsk, postnr, postadress,
betalningstid_dagar, moms, betald) VALUES ('"+s1+"', '"+s2+"', '"+s3+"',
'"+s4+"', '"+s5+"', "+s6+", "+s7+", '"+s8+"', '"+s9+"', '"+s10+"',
'"+s11+"', '"+s12+"', '"+s13+"', '"+s14+"', '"+s15+"', '"+s16+"', "+s17+",
"+s18+")"
insert_Multi.Execute
If (Err.Description <"") Then
FX_sqlerror = FX_sqlerror & "Row " & N & ": " & Err.Description &
"<br><br>"
End If
End If
Next
insert_Multi.ActiveConnection.Close
thispath = cStr(Request.ServerVariables("SCRIPT_NAME"))
If (FX_insredir = "") Then FX_insredir = Mid(thispath, InstrRev(thispath,
"/")+1) End If
If (Request.QueryString <"") Then
ch = "&"
If (InStr(FX_insredir,"?") = 0) Then ch = "?" End If
FX_insredir = FX_insredir & ch & Request.QueryString
End If
If (FX_sqlerror <"") Then
Response.Write("<font color=""red"">"&FX_sqlerror&"</font>")
Else Response.Redirect(FX_insredir) End If
End If
%>
<!--#include file="ewconfig.asp"-->
<!--#include file="db.asp"-->
<!--#include file="fakturainfo.asp"-->
<!--#include file="advsecu.asp"-->
<!--#include file="aspmkrfn.asp"-->
<!--#include file="ewupload.asp"-->
<%
If Not IsLoggedIn Then Response.Redirect "login.asp"
%>
<!--#include file="header.asp"-->
<p><form ACTION="<%=MM_editAction%>" METHOD="POST" name="form_fakturera"
class="ewTable" id="form_fakturera">
<br />
Skriv in text som syns på varje faktura denna månad:
<br />
<input name="faktura_id" type="hidden" id="faktura_id" value="">
<% ins_rs_fakturera = ins_rs_fakturera+1 %>
<textarea name="txt_egen_fakturatext" cols="60" rows="2"></textarea>
<table width="98%" border="0" cellspacing="0" class="ewTable">
<tr class="ewTableHeader">
<th scope="col"><div align="left">Namn</div></th>
<th scope="col"><div align="left">Hyresbostad</div></th>
<th scope="col"><div align="left">Näradress</div></th>
<th scope="col"><div align="left">Telefon</div></th>
<th scope="col"><div align="left">Fakturatext</div></th>
<th scope="col"><div align="left">Månadshyra</div></th>
<th scope="col"><div align="left">Moms</div></th>
</tr>
<%
While ((Repeat1__numRows <0) AND (NOT rs_fakturera.EOF))
%>
<tr >
<td>
<%=(rs_fakturera.Fields.Item("Efternamn").Value)%> <%=(rs_fakturera.Fields.Item("Fornamn").Valu e)%>
<input name="hiddenField_daum<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_daum" value="<%=date()%>">
<input name="hiddenField_manad_ar<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_manad_ar" value="<%=month(now) & "_" &
year(now)%>">
<input name="hiddenField_efternamn<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_efternamn"
value="<%=(rs_fakturera.Fields.Item("Efternamn").V alue)%>">
<input name="hiddenField_fornamn<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_fornamn"
value="<%=(rs_fakturera.Fields.Item("Fornamn").Val ue)%>">
<input name="hiddenField_kund_id<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_kund_id"
value="<%=(rs_fakturera.Fields.Item("Id").Value)%> "></td>
<td><%=(rs_fakturera.Fields.Item("Namn").Value)% >
<input name="hiddenField_hyresbostad<%=ins_rs_fakturera%> "
type="hidden" id="hiddenField_hyresbostad"
value="<%=(rs_fakturera.Fields.Item("Hyresbostad") .Value)%>">
<input name="hiddenField_bostadsnamn<%=ins_rs_fakturera%> "
type="hidden" id="hiddenField_bostadsnamn"
value="<%=(rs_fakturera.Fields.Item("Namn").Value) %>"></td>
<td><%=(rs_fakturera.Fields.Item("Naradress").Valu e)%>
<input name="hiddenField_naradress<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_naradress"
value="<%=(rs_fakturera.Fields.Item("Naradress").V alue)%>"></td>
<td><%if (rs_fakturera.Fields.Item("telefon").Value) <"" then%>
<%=(rs_fakturera.Fields.Item("telefon").Value)%>&n bsp;
<%if (rs_fakturera.Fields.Item("mobiltelefon").Value) <""
then%>
<%=(rs_fakturera.Fields.Item("mobiltelefon").Value )%>
<%end if
end if
%>
<input name="hiddenField_telefon<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_telefon" value="<%if
(rs_fakturera.Fields.Item("telefon").Value) <"" then%>
<%=(rs_fakturera.Fields.Item("telefon").Value)%>&n bsp;
<%if (rs_fakturera.Fields.Item("mobiltelefon").Value) <"" then%>
<%=(rs_fakturera.Fields.Item("mobiltelefon").Value )%>
<%end if
end if
%>"></td>
<td><%=(rs_fakturera.Fields.Item("text_pa_faktura" ).Value)%>
<input name="hiddenField_fakturatext<%=ins_rs_fakturera%> "
type="hidden" id="hiddenField_fakturatext"
value="<%=(rs_fakturera.Fields.Item("text_pa_faktu ra").Value)%>"></td>
<td><%=(rs_fakturera.Fields.Item("Manadshyra").Val ue)&":-"%>
<input name="hiddenField_manadshyra<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_manadshyra"
value="<%=(rs_fakturera.Fields.Item("Manadshyra"). Value)%>">
<input name="hiddenField_finsk<%=ins_rs_fakturera%>"
type="hidden" value="<%if (rs_fakturera.Fields.Item("Finsk").Value) = True
then response.Write(-1) else response.Write("0")%>">
<input name="hiddenField_postnr<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_postnr"
value="<%=(rs_fakturera.Fields.Item("postnr").Valu e)%>">
<input name="hiddenField_postadress<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_postadress"
value="<%=(rs_fakturera.Fields.Item("postadress"). Value)%>">
<input name="hiddenField_betalningstid<%=ins_rs_fakturera %>"
type="hidden" id="hiddenField_betalningstid"
value="<%=(rs_fakturera.Fields.Item("Betalningstid _dagar").Value)%>"></td>
<td><center>
<input name="hiddenField_moms<%=ins_rs_fakturera%>"
type="hidden" value="<%if (rs_fakturera.Fields.Item("moms").Value) = True
then response.Write(-1) else response.Write("0")%>">
<%if (rs_fakturera.Fields.Item("moms").Value) = True then
response.Write("Ja") ELSE response.Write("Nej")%>
<input name="hiddenField_betald<%=ins_rs_fakturera%>"
type="hidden" id="hiddenField_betald" value="">
</center></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_fakturera.MoveNext()
Wend
%>
</table>
<br>
<table width="98%" border="0" cellspacing="0" class="ewListAdd">
<tr>
<td><div align="right">
<input type="submit" name="Submit" value=" Fakturera
»»">
</div></td>
</tr>
</table>
</form>
<!--#include file="footer.asp"-->
<%
rs_fakturera.Close()
Set rs_fakturera = Nothing
%>