By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,386 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,386 IT Pros & Developers. It's quick & easy.

Textarea outside of loop

P: n/a
Jen
Hi. I have this problem that I think should be easy but have been struggling
with this for days.
I have a list based on a recordset from a database. This list consists of
records meeting a certain criteria and at the bottom of this list i have a
button that inserts all these records to aŽnother table in the database. So
long everything's ok.
BUT, at the top of this list I have a textarea that the user can write down
some text to be put into every record in the table also. I can't loop this
textarea, then I would have to fill out them all anyway.
I think that some variable witch fetched the text from an onload popup
window by request.form or javascript prompt would do the trick but I'm not
sure if it's possible or even how to do this. -And, I would like to have the
textarea at the top of the page instead of some silly popup thing.

How could I achieve this?
Dec 19 '06 #1
Share this Question
Share on Google+
16 Replies


P: n/a
need to see your code
"Jen" <je*@hoganmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi. I have this problem that I think should be easy but have been
struggling with this for days.
I have a list based on a recordset from a database. This list consists of
records meeting a certain criteria and at the bottom of this list i have a
button that inserts all these records to aŽnother table in the database.
So long everything's ok.
BUT, at the top of this list I have a textarea that the user can write
down some text to be put into every record in the table also. I can't loop
this textarea, then I would have to fill out them all anyway.
I think that some variable witch fetched the text from an onload popup
window by request.form or javascript prompt would do the trick but I'm not
sure if it's possible or even how to do this. -And, I would like to have
the textarea at the top of the page instead of some silly popup thing.

How could I achieve this?


Dec 19 '06 #2

P: n/a
Jen wrote:
Hi. I have this problem that I think should be easy but have been
struggling with this for days.
I have a list based on a recordset from a database. This list
consists of records meeting a certain criteria and at the bottom of
this list i have a button that inserts all these records to aŽnother
table in the database. So long everything's ok.
BUT, at the top of this list I have a textarea that the user can
write down some text to be put into every record in the table also. I
can't loop this textarea, then I would have to fill out them all
anyway. I think that some variable witch fetched the text from an onload
popup
window by request.form or javascript prompt would do the trick but
I'm not sure if it's possible or even how to do this. -And, I would
like to have the textarea at the top of the page instead of some
silly popup thing.
How could I achieve this?
This sounds "wrong-headed" for two reasons:

1. You are storing data (rows) in two separate places in the database.
Unless this is some sort of archiving scheme, this practice will typically
lead to maintenance nightmares.
2. You are storing the same data into multiple rows in a table. I cannot
fathom a possible reason for doing this. Could you explain please?

Having said that, I don't understand the problem you are having. "Looping"
through a textarea should not have even entered your mind if I am
understanding your requirements correctly: simply assign the text in the
textarea to a variable and use that variable in your insert statements. Why
would you even be thinking about a popup window?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Dec 19 '06 #3

P: n/a

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:uD****************@TK2MSFTNGP03.phx.gbl...
Jen wrote:
>Hi. I have this problem that I think should be easy but have been
struggling with this for days.
I have a list based on a recordset from a database. This list
consists of records meeting a certain criteria and at the bottom of
this list i have a button that inserts all these records to aŽnother
table in the database. So long everything's ok.
BUT, at the top of this list I have a textarea that the user can
write down some text to be put into every record in the table also. I
can't loop this textarea, then I would have to fill out them all
anyway. I think that some variable witch fetched the text from an onload
popup
window by request.form or javascript prompt would do the trick but
I'm not sure if it's possible or even how to do this. -And, I would
like to have the textarea at the top of the page instead of some
silly popup thing.
How could I achieve this?

This sounds "wrong-headed" for two reasons:

1. You are storing data (rows) in two separate places in the database.
Unless this is some sort of archiving scheme, this practice will typically
lead to maintenance nightmares.
2. You are storing the same data into multiple rows in a table. I cannot
fathom a possible reason for doing this. Could you explain please?

Having said that, I don't understand the problem you are having. "Looping"
through a textarea should not have even entered your mind if I am
understanding your requirements correctly: simply assign the text in the
textarea to a variable and use that variable in your insert statements.
Why would you even be thinking about a popup window?


my thoughts also,

Need to see code

>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Dec 19 '06 #4

P: n/a
Jen
1. You are storing data (rows) in two separate places in the database.
Unless this is some sort of archiving scheme, this practice will typically
lead to maintenance nightmares.
2. You are storing the same data into multiple rows in a table. I cannot
fathom a possible reason for doing this. Could you explain please?

Having said that, I don't understand the problem you are having. "Looping"
through a textarea should not have even entered your mind if I am
understanding your requirements correctly: simply assign the text in the
textarea to a variable and use that variable in your insert statements.
Why would you even be thinking about a popup window?

1. This won't lead to any maintenance nightmares(well, one can hope, I'm
not that good at this as you can see ;), these tables are linked in a
relationship.
2. I am not storing any same data into multiple rows in a table. Basically,
this is a simple monthly billing app. I have one table holding the tenant's
data (name and addresses, monthly rent's & other monthly payments, unique
text to print on the bill for the actual tenant etc. etc.), one (linked)
table holding the landlord's 80-90 apartemnt's and one (unlinked) table with
the landlord's data (bank-accounts etc.)
Then I have this linked table consisting of the bills.
The landlord wants to open (log on to) this app once a month online and
simply write something that is unique for the actual month (the name of the
year & month, some christmas greetings.. for example, and here's the
textarea causing me the headache), klick on print at the bottom of the list
and every bill is printed out at the same time as these are written into the
bills table. And presto, the landlord is done for the month with wery little
effort. The bills are later wiewable all by month or by apartment or by
tenant in a timeframe that is choosen.
How would I assign a textarea to a variable on the same page? I'm reading
this can't be done (http://www.dmxzone.com/forum/topic.asp?topic_id=15746),
thus my thoughts on some popup solution.

Please bear with me, I'm new at this stuff, and on top of that my english
isn't that good my mothertung being swedish
:[

Jen.
>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Dec 19 '06 #5

P: n/a

"Jen" <je*@hoganmail.comwrote in message
news:OX****************@TK2MSFTNGP03.phx.gbl...
>1. You are storing data (rows) in two separate places in the database.
Unless this is some sort of archiving scheme, this practice will
typically lead to maintenance nightmares.
2. You are storing the same data into multiple rows in a table. I cannot
fathom a possible reason for doing this. Could you explain please?

Having said that, I don't understand the problem you are having.
"Looping" through a textarea should not have even entered your mind if I
am understanding your requirements correctly: simply assign the text in
the textarea to a variable and use that variable in your insert
statements. Why would you even be thinking about a popup window?

1. This won't lead to any maintenance nightmares(well, one can hope, I'm
not that good at this as you can see ;), these tables are linked in a
relationship.

2. I am not storing any same data into multiple rows in a table.
Basically, this is a simple monthly billing app. I have one table holding
the tenant's data (name and addresses, monthly rent's & other monthly
payments, unique text to print on the bill for the actual tenant etc.
etc.), one (linked) table holding the landlord's 80-90 apartemnt's and one
(unlinked) table with the landlord's data (bank-accounts etc.)
Then I have this linked table consisting of the bills.
The landlord wants to open (log on to) this app once a month online and
simply write something that is unique for the actual month (the name of
the year & month, some christmas greetings.. for example, and here's the
textarea causing me the headache), klick on print at the bottom of the
list and every bill is printed out at the same time as these are written
into the bills table. And presto, the landlord is done for the month with
wery little effort. The bills are later wiewable all by month or by
apartment or by tenant in a timeframe that is choosen.
How would I assign a textarea to a variable on the same page? I'm reading
this can't be done
(http://www.dmxzone.com/forum/topic.asp?topic_id=15746), thus my thoughts
on some popup solution.

why cant it be done.

This seems like a simple job

We need to see your code
>
Please bear with me, I'm new at this stuff, and on top of that my english
isn't that good my mothertung being swedish
:[

Jen.
>>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Dec 19 '06 #6

P: n/a
Jen wrote:
>1. You are storing data (rows) in two separate places in the
database. Unless this is some sort of archiving scheme, this
practice will typically lead to maintenance nightmares.
2. You are storing the same data into multiple rows in a table. I
cannot fathom a possible reason for doing this. Could you explain
please?

Having said that, I don't understand the problem you are having.
"Looping" through a textarea should not have even entered your mind
if I am understanding your requirements correctly: simply assign the
text in the textarea to a variable and use that variable in your
insert statements. Why would you even be thinking about a popup
window?

1. This won't lead to any maintenance nightmares(well, one can hope,
I'm not that good at this as you can see ;), these tables are linked
in a relationship.

2. I am not storing any same data into multiple rows in a table.

That's how I interpreted this:
" ... some text to be put into every record in the table also."
Basically, this is a simple monthly billing app. I have one table
holding the tenant's data (name and addresses, monthly rent's & other
monthly payments, unique text to print on the bill for the actual
tenant etc. etc.), one (linked) table holding the landlord's 80-90
apartemnt's and one (unlinked) table with the landlord's data
(bank-accounts etc.)
Then I have this linked table consisting of the bills.
The landlord wants to open (log on to) this app once a month online
and simply write something that is unique for the actual month (the
name of the year & month, some christmas greetings.. for example, and
here's the textarea causing me the headache), klick on print at the
bottom of the list and every bill is printed out at the same time as
these are written into the bills table. And presto, the landlord is
done for the month with wery little effort. The bills are later
wiewable all by month or by apartment or by tenant in a timeframe
that is choosen.
So you should create a table to contain the monthly message: one record
per month. use a join to link the monthly message to the bills paid for
that month
How would I assign a textarea to a variable on the same page? I'm
reading this can't be done
(http://www.dmxzone.com/forum/topic.asp?topic_id=15746),
What do you mean? There are two examples of doing it on that page. I
suspect Brian was not expressing himself very well.
thus my
thoughts on some popup solution.
I still don't understand why that would be relevant.
>
Please bear with me, I'm new at this stuff, and on top of that my
english isn't that good my mothertung being swedish
Your english is better than my swedish :-)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 19 '06 #7

P: n/a
Jen
So you should create a table to contain the monthly message: one record
per month. use a join to link the monthly message to the bills paid for
that month
>How would I assign a textarea to a variable on the same page? I'm
reading this can't be done
(http://www.dmxzone.com/forum/topic.asp?topic_id=15746),

What do you mean? There are two examples of doing it on that page. I
suspect Brian was not expressing himself very well.
>thus my
thoughts on some popup solution.

I still don't understand why that would be relevant.
>>
Please bear with me, I'm new at this stuff, and on top of that my
english isn't that good my mothertung being swedish

Your english is better than my swedish :-)
--
If a textarea is on the same page that the sql insert code, 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? This is why
I talked about some popup window where I could get the text from a textarea
in this popup window into an variable with request.form.
Anyways, here's the code (form) if that can help you guys help me. I really
do appretiate you taking the time to try to help out us beginners.

<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form_fakturera"
class="ewTable" id="form_fakturera">
<br />
Skriv in text som syns p&aring; varje faktura denna m&aring;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&auml;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&aring;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)%> &nbsp;<%=(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
&raquo;&raquo;">
</div></td>
</tr>
</table>
</form>
Dec 19 '06 #8

P: n/a
Jen wrote:
If a textarea is on the same page that the sql insert code,
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>

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 19 '06 #9

P: n/a
Jen
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&aring; varje faktura denna m&aring;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&auml;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&aring;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)%> &nbsp;<%=(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
&raquo;&raquo;">
</div></td>
</tr>
</table>
</form>
<!--#include file="footer.asp"-->
<%
rs_fakturera.Close()
Set rs_fakturera = Nothing
%>

Dec 19 '06 #10

P: n/a
Jen wrote:
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.

Now we have a fundamental problem. Nothing server-side can be refreshed
without a form submission. This is pretty basic. In order for something
to happen on the server, something has to be sent to the server.

Using an xmlhttp object, data can be submitted to the server without
leaving/refreshing your page. This again is client-side code so I'm
going to ask you to google the subject and post any further question you
have to a client-side group.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 19 '06 #11

P: n/a
Jen
Now we have a fundamental problem. Nothing server-side can be refreshed
without a form submission. This is pretty basic. In order for something
to happen on the server, something has to be sent to the server.

Using an xmlhttp object, data can be submitted to the server without
leaving/refreshing your page. This again is client-side code so I'm
going to ask you to google the subject and post any further question you
have to a client-side group.
Please, I do understand this server-side/ client-side refresh problem, thats
the core of my problem, no need to stress this out forever and ask me to
leave the group only if you don't have the answer to my initial basic
question. The refresh-thing wont work.
You were basically wrong in your earlier statements?:

"simply assign the text in the
textarea to a variable and use that variable in your insert statements. Why
would you even be thinking about a popup window?"
How would I assign a textarea to a variable on the same page? I'm
reading this can't be done
(http://www.dmxzone.com/forum/topic.asp?topic_id=15746),
"What do you mean? There are two examples of doing it on that page. I
suspect Brian was not expressing himself very well.
I still don't understand why that [popup] would be relevant."

Thanks for taking the time to answering though and happy holidays to you.

Anybody else that could answer this initial question of mine:?
I have a list based on a recordset from a database. This list consists of
records meeting a certain criteria and at the bottom of this list i have a
button that inserts all these records to aŽnother table in the database. So
long everything's ok.
BUT, at the top of this list I have a textarea that the user can write down
some text to be put into every record in the table also. I can't loop this
textarea, then I would have to fill out them all anyway.
A screenshot can be found here: http://www.comtech.fi/filer/example.gif
I think that some variable witch fetched the text from an onload popup
window by request.form or javascript prompt would do the trick but I'm not
sure if it's possible or even how to do this. -And, I would like to have the
textarea at the top of the page instead of some silly popup thing.

Jen.
Dec 20 '06 #12

P: n/a
Jen
Got it working using a popup window. Thanks to all and a merry christmas.

Jen.
Dec 20 '06 #13

P: n/a
There was no need to use a popup window. Popups are messy way to gain input

Can we see the code of your popup window?

Is this code produced by some sort of editor?
"Jen" <je*@hoganmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Got it working using a popup window. Thanks to all and a merry christmas.

Jen.

Dec 20 '06 #14

P: n/a
Jen
Slim, instead of keeping asking a lot, giving everyone an image of that you
are so good at this and never telling anything of value anyway, you got the
code you asked for before, why don't you show how to do this without the
popup window? :)

Jen.

"Slim" <me@here.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
There was no need to use a popup window. Popups are messy way to gain
input

Can we see the code of your popup window?

Is this code produced by some sort of editor?
"Jen" <je*@hoganmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Got it working using a popup window. Thanks to all and a merry christmas.

Jen.


Dec 20 '06 #15

P: n/a

"Jen" <je*@hoganmail.comwrote in message
news:eB**************@TK2MSFTNGP02.phx.gbl...
Slim, instead of keeping asking a lot, giving everyone an image of that
you are so good at this and never telling anything of value anyway, you
got the code you asked for before, why don't you show how to do this
without the popup window? :)

let us see the code of your popup and then I may be able to understand where
your going wrong.

You said you wanted to post these rows into a new table, this seems wrong,
as you already have the data, all you need to do is mark that data and link
it to the invoice message. To insert it into a new table you need to submit
to the server, why cant you submit the textarea along with the data you
have?

You have the data on the page, what is the next action, are you going to
insert it into a new table?
if so it is simple, write your mesage into the text box and submit it also.

Jen.

"Slim" <me@here.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>There was no need to use a popup window. Popups are messy way to gain
input

Can we see the code of your popup window?

Is this code produced by some sort of editor?
"Jen" <je*@hoganmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Got it working using a popup window. Thanks to all and a merry
christmas.

Jen.



Dec 20 '06 #16

P: n/a
Jen wrote:
>Now we have a fundamental problem. Nothing server-side can be
refreshed without a form submission. This is pretty basic. In order
for something to happen on the server, something has to be sent to the
server.

Using an xmlhttp object, data can be submitted to the server without
leaving/refreshing your page. This again is client-side code so I'm
going to ask you to google the subject and post any further question
you have to a client-side group.

Please, I do understand this server-side/ client-side refresh
problem, thats the core of my problem, no need to stress this out
forever and ask me to leave the group only if you don't have the
answer to my initial basic question. The refresh-thing wont work.
The fact that you say "refresh" makes me doubt this. But let's leave that
aside.
I didn't ask you to "leave this group": I asked you to post client-side
scripting questions to a more appropriate group. If you have asp-related
questions, I hope you will continue to post them here.
>
You were basically wrong in your earlier statements?:

"simply assign the text in the
textarea to a variable and use that variable in your insert
statements. Why would you even be thinking about a popup window?"
No, I wasn't wrong. I was perfectly correct.
I think I now understand what you were doing with that popup window: you had
a form in it which you used to submit the value to the server, correct?

I reiterate: it is not necessary to do this. You can use xmlhttp (as I said
in my earlier post) to submit data to the server without submitting the rest
of the page ("refresh" as you called it). At the risk of perpetuating this
thread in the wrong newsgroup, here is a working example:

First create a page that does nothing but handle the value from the textarea
and returns a success/failure code:

HandleTextArea.asp:
<%
dim textvar
textvar=Request.Form("txt_egen_fakturatext")
'mitigate sql injection attacks*
textvar=replace(textvar,"'","''")
sql="insert ... values ('" & textvar & "')"
on error resume next
'execute the sql
if err<>0 then
Response.Write "1"
else
Response.Write "0"
end if
%>

* If you would like more information about avoiding sql injection in your
server-side code, please let me know and I will provide it.

Then use xmlhttp to submit the textarea value:
SubmitByXMLHTTP.htm:
<html>
<head>
<script type="text/javascript">
var EnteredText
function handleChange(obj)
{
EnteredText=obj.value;
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
var node=xmldoc.createElement("textarea");
node.text=EnteredText;
xmldoc.documentElement=node ;
if (SubmitXML("HandleTextArea.asp",xmldoc,"handleChan ge"))
{
node=xmldoc.documentElement;
alert(node.text);
}
else
alert("unsuccessful submission")
}
function SubmitXML (pURL, pxmldoc, pSource)
{
//I keep this in a library.js file so it is easily reused
var oHTTP = new ActiveXObject("Microsoft.XMLHTTP");
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
oHTTP.open("POST",pURL, false);
oHTTP.send(pxmldoc);
var bStatus= xmldoc.loadXML(oHTTP.responseText)
if (bStatus == false)
{
var xPE = xmlDoc.parseError
strMessage = "errorCode = " + xPE.errorCode + "\n"
strMessage += "reason = " + xPE.reason + "\n"
strMessage += "Line = " + xPE.Line + "\n"
strMessage += "linepos = " + xPE.linepos + "\n"
strMessage += "filepos = " + xPE.filepos + "\n"
strMessage += "srcText = " + xPE.srcText + "\n"
alert(pSource + ":\n" + strMessage);
return false
}
pxmldoc.loadXML(xmldoc.xml);
return true;
}
</script>
</head>
<body>
<textarea name="txt_egen_fakturatext" cols="60" rows="2"
onchange="handleChange(this);">
</textarea>
</body>
</html>

I used the .htm file extension to reiterate that this is a client-side
scripting question. If you have any questions about the code in this
example, please take them to m.p.scripting.jscript.

Of course, if you have questions about the server-side vbscript contained in
HandleTextArea.asp, feel free to ask them here.

I'm now late for work. I am also done with this thread unless asp-related
questions are asked.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Dec 20 '06 #17

This discussion thread is closed

Replies have been disabled for this discussion.