Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays On ASP from Days of week 1

Status
Not open for further replies.

jofarrell

Programmer
Mar 21, 2001
178
0
0
US
This may seem like a silly question but ....

I have a time sheets ASP page I am creating, I have looped through and got my recordset (rs) that I need from the database and have places it in my table (which looks ugly at the moment) across from each row of the rs I need Mon - Sun text boxes to appear as well as a total of the week. Does anyone have any suggestions on how I can set this up inside my exisiting loop??

Thank you in advance

Joanne
 
I think I know what you are trying to do...
Firstly, build up a date array such as:
<%
Dim strDay(8)
strDay(1) = &quot;Mon&quot;
strDay(2) = &quot;Tue&quot;
strDay(3) = &quot;Wed&quot; etc...
%>
Then, in your While Not rs.EOF loop, display the data on the page as such:
<%
x = 1
While Not rs.EOF
Response.Write &quot;<tr><td>&quot; & rs(&quot;data1&quot;) & &quot;</td><td>&quot; & strDay(x) & &quot;</td></tr>&quot;
x = x + 1
rs.MoveNext
Wend
%>

You'll probably have to tweak this a little but it should give you an idea.

Hope this helps,

Chris
 
Chris

Thank you!!! I am trying it now and it does give me a few ideas :)

Much appreciated.

Joanne
 
I have another part to this problem, I need textboxes for them to enter their time into for each row of the record .. so there would be a Monday(), Tueday() etc up to the recordcount of the recordset. I want to dymanically create these text boxes into the table but I get a syntax error. Any suggestions on who to do this? My loop is as follows :

Do While Not rs.Eof

Compound = rs(&quot;sdCompoundNo&quot;)
Protocol = rs(&quot;sdProtocolNo&quot;)
TheraArea = rs(&quot;sdTherapeuticArea&quot;)
Description = rs(&quot;sdAcronym&quot;)
' Training Table Data

Response.Write (&quot;<tr>&quot; & &quot;<td>&quot; & Compound & &quot;</td>&quot; & &quot;<td>&quot; & Protocol & &quot;</td>&quot; & &quot;<td>&quot; & TheraArea & &quot;</td>&quot; & &quot;<td>&quot; & Description & &quot;</td>&quot; & VbCrLf & &quot; </tr>&quot;)
rs.movenext
Loop


Its messy but I need to keep ot all on same row as have the 8 text boxes after the dats

Thanks again

Joanne
 
Try...

<%
Count = 1
Do While Not rs.Eof

Compound = rs(&quot;sdCompoundNo&quot;)
Protocol = rs(&quot;sdProtocolNo&quot;)
TheraArea = rs(&quot;sdTherapeuticArea&quot;)
Description = rs(&quot;sdAcronym&quot;)
' Training Table Data

Response.Write (&quot;<tr>&quot; & &quot;<td>&quot; & Compound & &quot;<INPUT NAME=COMPOUND<%=COUNT%>>&quot; & &quot;</td>&quot; & &quot;<td>&quot; & Protocol & &quot;<INPUT NAME=PROTOCOL<%=COUNT%>>&quot; & &quot;</td>&quot; & &quot;<td>&quot; & TheraArea & &quot;<INPUT NAME=THERAAREA<%=COUNT%>>&quot; & &quot;</td>&quot; & &quot;<td>&quot; & Description & &quot;<INPUT NAME=DESCRIPTION<%=COUNT%>>&quot; & &quot;</td>&quot; & VbCrLf & &quot; </tr>&quot;)
COUNT=COUNT+1
rs.movenext
Loop
%>

Hope this Helps...

Gee -GTM Solutions, Home of USITE-
-=
 
I get another error when I include that. The code I gave before gives me what I need. I just need to include at the end of that 7 textboxes that will allow the user to enter times spent on each record I pull from the database.

Here is error I got

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/sanofi/newTS.asp, line 465

Response.Write (&quot;<tr>&quot; & &quot;<td>&quot; & Compound & &quot;<INPUT NAME=COMPOUND<%=COUNT
--------------------------------------------------------------------------^


 
heheheh... I thought this might get more complicated :)

you need to do a number of things:

firstly count the rows in the recordset using the getrows method:
x = rs.GetRows

add a counter:
y = x

then, within your loop, add a text input box:
Response.Write (&quot;<tr>&quot; & &quot;<td>&quot; & Compound & &quot;</td>&quot; & &quot;<td>&quot; & Protocol & &quot;</td>&quot; & &quot;<td>&quot; & TheraArea & &quot;</td>&quot; & &quot;<td>&quot; & Description & &quot;</td>&quot; & VbCrLf & &quot;<td><input type='text' name='time&quot; & y & &quot;'></td></tr>&quot;)

*nb: just a side note: why the vbCrLf line feed?

update the counter:
y = y + 1

now complete the loop.

then on subsequent pages the time data will be held in:
request.form(&quot;time1&quot;)
request.form(&quot;time2&quot;)
request.form(&quot;time3&quot;) etc...

Hope this helps,

Chris
 
I think the brackets are causing problems. Try...


<%
Count = 1
Do While Not rs.Eof

Compound = rs(&quot;sdCompoundNo&quot;)
Protocol = rs(&quot;sdProtocolNo&quot;)
TheraArea = rs(&quot;sdTherapeuticArea&quot;)
Description = rs(&quot;sdAcronym&quot;)
' Training Table Data

Response.Write &quot;<tr>&quot; & &quot;<td>&quot; & Compound & &quot;<INPUT NAME=COMPOUND<%=COUNT%>>&quot; & &quot;</td>&quot; & &quot;<td>&quot; & Protocol & &quot;<INPUT NAME=PROTOCOL<%=COUNT%>>&quot; & &quot;</td>&quot; & &quot;<td>&quot; & TheraArea & &quot;<INPUT NAME=THERAAREA<%=COUNT%>>&quot; & &quot;</td>&quot; & &quot;<td>&quot; & Description & &quot;<INPUT NAME=DESCRIPTION<%=COUNT%>>&quot; & &quot;</td>&quot; & VbCrLf & &quot; </tr>&quot;)
COUNT=COUNT+1
rs.movenext
Loop
%>

Hope this Helps

G -GTM Solutions, Home of USITE-
-=
 
you can't use the <% %> string identifiers within a response.write object (since you are already within <%%> string identifiers for the whole script)...

try using:

Response.Write &quot;<tr><td>&quot; & Compound & &quot;<INPUT NAME=COMPOUND&quot; & COUNT & &quot;></td><td>&quot; & Protocol & &quot;<INPUT NAME=PROTOCOL&quot; & COUNT & &quot;></td><td>&quot; & TheraArea & &quot;<INPUT NAME=THERAAREA&quot; & COUNT & &quot;></td><td>&quot; & Description & &quot;<INPUT NAME=DESCRIPTION&quot; & COUNT & &quot;></td>&quot; & VbCrLf & &quot; </tr>&quot;

If you want to use this method. Bear in mind that this method will give you a text input box after each object and not just one for each whole record.

PS: still don't get the reason for the vbcrlf command.

Chris
 
heh things always seem to have a way of getting more complicated with me, and why the line feed?? Good question and I was removing them before you asked.

Ok here is error I NOW get

Response object error 'ASP 0106 : 80020005'
Type Mismatch

?

An unhandled data type was encountered.


with this code

rs.movefirst
x = rs.GetRows()
y = x
response.write(x)
Do While Not rs.Eof

Compound = rs(&quot;sdCompoundNo&quot;)
Protocol = rs(&quot;sdProtocolNo&quot;)
TheraArea = rs(&quot;sdTherapeuticArea&quot;)
Description = rs(&quot;sdAcronym&quot;)


Response.Write (&quot;<tr>&quot; & &quot;<td>&quot; & Compound & &quot;</td>&quot; & &quot;<td>&quot; & Protocol & &quot;</td>&quot; & &quot;<td>&quot; & TheraArea & &quot;</td>&quot; & &quot;<td>&quot; & Description & &quot;</td>&quot; & &quot;<td><input type='text' name='time&quot; & y & &quot;'></td></tr>&quot;)
rs.movenext
y = y + 1
Loop


Sorry to be such a dufus with this but I have never dynamically created textboxes before based on my record count.


Thanks again for all your help and as you can tell I need more :)

Joanne



 
oops...

try y = Cint(x)

mismatch between differing variable types (Cint converts the contents of x to an integer)

I'm off home for the evening now, but if you get really stuck mail the stuff to me at chris@communicopia.co.uk and see if I can suss it out tomorrow.

Chris
 
Do I have to end my asp tags before I can add the textboxes?? *sniff* this is making me crazier than normal

Joanne
 
nope...

enclose the text boxes in the response.write statements as such:

<%

response.write &quot;this is some text&quot; & a_variable & &quot;<input type='text' name='a_text_box'>&quot;

%>

ok?

Chris
 
*heavy sigh*

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'CInt'

/sanofi/newTS.asp, line 455


How about I just give up programming and join the circus?

Joanne
 
You get a data type error because getrows returns an array. You can't do a y = Cint(x), because you can't convert an array to an integer.

If you need to count the rows in a recordset, you can do so by calling .RecordCount
in this instance, it would be RS.RecordCount

You need to remember to specify a cursor that can move backwards, though, before you can use .RecordCount, such as adOpenStatic.

see Paul's FAQ on the recordset properties to get a good handle on this.

faq333-618

If you plan on using GetRows, you'll see a signifcant speed increase from using the Array, but you'll also have to undergo a huge code overhaul.

anyways -
there's no need for you to join the circus. i heard that you get paid peanuts anyhow... ok i'll stop now.

:)
leo
 
*grin* Thank you Leo,

and lucky for me I like peanuts :)

Joane
 
I want to thank Chris for going above and beyond the call of duty. As you can tell I may not be a big help with web development but if you ever need VB or database aid let me know. I would be happy to return the favour.


:)
Joanne

(Has a much nicer looking table!!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top