Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: format textarea


Message #1 by strtbikr2002@y... on Tue, 11 Mar 2003 16:00:54
Hello everyone!

I am populating a textarea in a form with values from a database. Like so..

<textarea name="txtDetails" cols="77" rows="12">

<%
while Not RS.EOF

Response.Write RS("Date") & "&nbsp;&nbsp;" & RS("Quantity") 
& "&nbsp;&nbsp;" & RS("Description") _
& "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("UnitPrice"),2,0) _ 
& "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("Amount"),2) _
& "&nbsp;&nbsp;&nbsp;" & RS("Cd") & vbCr

RS.MoveNext
Wend
%>

</textarea>

Even though this works it doesn't give me the desired format I would like.
Is there a way to format or assign the db values to columns in the 
textarea via vbscript or javascript? Such as:

DATE    QUANTITY    DESCRIPTION                  UNIT PRICE    AMOUNT  CD 
-------------------------------------------------------------------------
col_no1. col?.      col?.rs.value             col?.rs.value    col?.  col?.
rs.value rs.value                                             rs.val rs.val

Message #2 by "Neil Jones" <neil@c...> on Tue, 11 Mar 2003 11:02:57 -0500
You can loop through the recordset and populate an html table with it.  It
works well.
NJ

-----Original Message-----
From: strtbikr2002@y... [mailto:strtbikr2002@y...]
Sent: Tuesday, March 11, 2003 4:01 PM
To: ASP Web HowTo
Subject: [asp_web_howto] format textarea


Hello everyone!

I am populating a textarea in a form with values from a database. Like so..

<textarea name="txtDetails" cols="77" rows="12">

<%
while Not RS.EOF

Response.Write RS("Date") & "&nbsp;&nbsp;" & RS("Quantity")
& "&nbsp;&nbsp;" & RS("Description") _
& "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("UnitPrice"),2,0) _
& "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("Amount"),2) _
& "&nbsp;&nbsp;&nbsp;" & RS("Cd") & vbCr

RS.MoveNext
Wend
%>

</textarea>

Even though this works it doesn't give me the desired format I would like.
Is there a way to format or assign the db values to columns in the
textarea via vbscript or javascript? Such as:

DATE    QUANTITY    DESCRIPTION                  UNIT PRICE    AMOUNT  CD
-------------------------------------------------------------------------
col_no1. col?.      col?.rs.value             col?.rs.value    col?.  col?.
rs.value rs.value                                             rs.val rs.val


Message #3 by "Peter Alldis" <peter@a...> on Tue, 11 Mar 2003 16:29:27 -0000
You can convert RecordSet to a Table - drawback is you can't edit text once
published
Not sure if the code below is exactly right but the principle is correct.
Uses GetString function to convert recordset to string, inserting TABLE
delimitiers between fields and rows.
Creates a 'header' row using RecordSet field names. Then populates the table

'convert recordSet to a string with delimiters to produce a table
 strTable 
RS.GetString(adClipString,-1,"</TD><TD>","</TD></TR><TR><TD>","-")
 strTable = Left(strTable, Len(strTable)-8)

'create table and header row
     p_numberOfColumns = RS.fields.Count
    Response.write "<TABLE width='100%' BORDER=1><TR>"

   for x = 0 to (p_numberOfColumns - 1)
    Response.write "<TH Align='left'>" & Right(RS.Fields(x).Name,
Len(RS.Fields(x).Name)-8) &"</TH>"
   next

 'populate table
  Response.write  "</TR><TR><TD>" & strTable & "</TABLE>"


Good Luck

----- Original Message -----
From: <strtbikr2002@y...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Tuesday, March 11, 2003 4:00 PM
Subject: [asp_web_howto] format textarea


> Hello everyone!
>
> I am populating a textarea in a form with values from a database. Like
so..
>
> <textarea name="txtDetails" cols="77" rows="12">
>
> <%
> while Not RS.EOF
>
> Response.Write RS("Date") & "&nbsp;&nbsp;" & RS("Quantity")
> & "&nbsp;&nbsp;" & RS("Description") _
> & "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("UnitPrice"),2,0) _
> & "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("Amount"),2) _
> & "&nbsp;&nbsp;&nbsp;" & RS("Cd") & vbCr
>
> RS.MoveNext
> Wend
> %>
>
> </textarea>
>
> Even though this works it doesn't give me the desired format I would like.
> Is there a way to format or assign the db values to columns in the
> textarea via vbscript or javascript? Such as:
>
> DATE    QUANTITY    DESCRIPTION                  UNIT PRICE    AMOUNT  CD
> -------------------------------------------------------------------------
> col_no1. col?.      col?.rs.value             col?.rs.value    col?.
col?.
> rs.value rs.value                                             rs.val
rs.val
>
>

Message #4 by strtbikr2002@y... on Tue, 11 Mar 2003 16:50:26
NJ,

Thanks for your suggestion.

I have done this in other pages, but for this page I need to use the 
textarea and allow editing to the textarea for notes, ect..

GA

> You can loop through the recordset and populate an html table with it.  
It
works well.
NJ

-----Original Message-----
From: strtbikr2002@y... [mailto:strtbikr2002@y...]
Sent: Tuesday, March 11, 2003 4:01 PM
To: ASP Web HowTo
Subject: [asp_web_howto] format textarea


Hello everyone!

I am populating a textarea in a form with values from a database. Like so..

<textarea name="txtDetails" cols="77" rows="12">

<%
while Not RS.EOF

Response.Write RS("Date") & "&nbsp;&nbsp;" & RS("Quantity")
& "&nbsp;&nbsp;" & RS("Description") _
& "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("UnitPrice"),2,0) _
& "&nbsp;&nbsp;&nbsp;&nbsp;" & FormatNumber(RS("Amount"),2) _
& "&nbsp;&nbsp;&nbsp;" & RS("Cd") & vbCr

RS.MoveNext
Wend
%>

</textarea>

Even though this works it doesn't give me the desired format I would like.
Is there a way to format or assign the db values to columns in the
textarea via vbscript or javascript? Such as:

DATE    QUANTITY    DESCRIPTION                  UNIT PRICE    AMOUNT  CD
-------------------------------------------------------------------------
col_no1. col?.      col?.rs.value             col?.rs.value    col?.  col?.
rs.value rs.value                                             rs.val rs.val



  Return to Index