Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    ASP




ASP Looping Adding


i have a variable in a database that is looping that outputs numbers like:

1. 45
2. 34
3. 94
4. 34

But are all in the same variable:

DoDateTime((rsBoxEdit.Fields.Item("").Value), 3, 2057)

How can i make it so that it loops that variable and adds the numbers up and outputs 1 variable called total or something?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
ASP Looping
I have a database with many fields. One of this field is of type memo
which contains some bullet points seperated by # sign (something along
those lines). What I have is this code which gives me a table with one
row and as many columns in the split array. Code:

Looping With Asp
I am trying to loop through my database to display a picture. That is no problem. Where I hit a snag is this. I only want three pictures then break to a new row and three more, etc. Any ideas? What this does is display one record. Code:

Looping
Is it possable to exit a loop in asp.

Looping
i got a problem regarding abt several looping running at the same time. I wanted the 1st loop to run once and then the 2nd loop to start running after the 1st loop ran once.. but the coding I do doesn't seem to be able to do that. Can sum1 teach mi how to do it?
The coding:

Looping In ASP
I am working on an asp page that goes to a rs to get data. I need to run a loop that pulls the data line by line until it is at the end of the database. I could do an Until loop, but I don't know how many records are in the recordset. So I suppose it should be a do until end-of-file?

Looping In ASP
In my arrary ListSong(), I have song names like (Song1.mp3,Song2.mp3,Song3.mp3,.....).

If the user selects more than one song, it should play one after the other. I want to do some looping for the <embed> tag. Here is my code:

<EMBED SRC="Songs/<%=ListSong(0)%>.mp3" VOLUME="50" AUTOSTART="true" HEIGHT="80" WIDTH="415">

SQL Looping
is there anyway to do a loop with an sql command in? Ive created a message board type of thing but its got the option to delete unwanted messages. next to each message there is a lil checkbox with the Record ID for the message as the name tag, what im trying to do is when a user clicks say 3 messages to remove it puts the id's of the checkbox's clicked into a query string or something and then loops deleting the messages in the database.sorta works like this

Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("databases/conkers.mdb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
messages = request.QueryString("ids")
for each value in messages do
mySQL = "DELETE FROM messages WHERE ID = '" &messages & "'"
Set RS = myConn.Execute(mySQL)
loop

Looping Through A Recordset
I have a recordset which writes out a table. As it is constructed now it loops through and repeats every record, but i want the last two rows to only appear once, but when I try to move the rsProd.MoveNext to where I want the loop to stop I get an error msg saying:

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. Code:

Looping Through Folder
I have a folder with about 40 swf training movies.
I want to loop through the folder and display the titles of the movies and make them links.I just need help getting pointed in the right direction to make this happen.

Looping Issues
I've got an Array that has split a text field in an Access DB. This Array is now: Array(0) = 1 and Array(1) = 3.

I have another field in another table that has a number and then the name associated with that number.I am wanting to display the name associated with 1 and 3 from my DB but a Do Loop isn't working. I presume because after it displays Array(0) (which it does well) the Looping condition is no longer true because there is no "2" in my array, it skips to 3. So Array(0) works because its true, but then it stops because there is no two but does not pick back up with Array(1).

Looping Through Database
I am working on creating reports from an access database. I am trying to populate a table created from the one-to-many relationships in the database. In one column a name appears more than once because it is related to multiple records.

When I display this information I would like to only show the name once in one column but show all of the records it is related to in another.

I have attached a spreadsheet the better explains what I am trying to do. The report is written asp and I have been using loops to write the data to the report. I have also attached the code I am using. The report uses values that the user selects from a map. Then it selects the same values in the database.

Looping Thru Array
I need to look at each element in an array to write it to the web page, one element at a time. The previous page contained a form of dynamically created checkbox sets. The number of checkbox sets will always be unknown. Anyway, here's my question:

I've tried different code (due to circumstances that would be to lengthy to get into here, I need to use vbscript, be able to use javascript within vbscript code.

Here are examples I've tried and the results: Code:

Looping Insert
I'm currently having some major problems with an insert form that I created
Basically, if a large amount of information is being inserted into the database I get an error
This seems to be a restriction imposed by the host
What I would ideally like to be able to do is to grab so many characters from the textarea insert this into the database and loop this until everything has been inserted (the information would all need to be inserted into the same field of a record)
I've never tried this before so would appreciate any advice/tips on how to go about doing this

Looping Problem
I am trying to loop through my database to display a picture. That is no problem. Where I hit a snag is this. I only want three pictures then break to a new row and three more, etc. Any ideas?

Looping Problem
I am trying to play multiple songs (as per the user selection) by using <embed> tag.
What is the loop condition I need to use to play the songs one by one. Ex:

<%
ListSong = (Song1.mp3,Song2.mp3) //(Array values differs)
For i = 0 to Ubound(ListSong)
<EMBED SRC="Songs/<%=ListSong(i)%>.mp3" VOLUME="50" AUTOSTART="true" HEIGHT="80" WIDTH="415">
Next
%>

But here the problem is: it's playing the last song in the array. But I need to play first Song1.mp3 and then Song2.mp3

Looping Through Recordset
I would like to split a recordset into two parts.
For example, in a left hand column I would to display upto the first 10 records and in the right hand column the next 10 records etc.
I would like this to work even if there are only 3/4 records in total (ie. Less than 10) - so the page would display the first 3/4 records in the left hand column and nothing in the right.
I would like to do this without the use of paging if poss as it needs to be pretty simple!

Problem With Looping
Im using the code below to create a calendar. The problem is when it comes to checking how many bookings have been taking on that day and colors it accordingly it doesnt go past the first day.

So say I have a booking on 1/1/2004 it will color it accordingly but wont color any of the rest of the days that have them on as well. Code:

Looping Checkboxes
I want somethingh like hotmail, where I don't know the exact amount of records displayed, but when the users checks the boxes and presses submit I can detect which boxes were checked and be able to perform the operation.

Looping Through Columns
Normally I do a query, and loop through the records. Is there a way to loop through the columns of each record?

Looping Variable
I have a variable that goes through a loop, and each time it appends the new value to the end using a comma. Example:

1st time through:
a = 1
2nd time through:
a = 1, 4
3rd time through:
a = 1, 4, 2

So now after my loop is all done I have this value where each value is seperated by a comma. What I want to do is compare each of the values and display only the largest number. Any ideas on how to do this?

Looping Problems
I'm have some trouble looping to the end of all the items that i split apart by a comma....mainly just displaying all the items in the string. Code:

set RS2Name001 = MyConn.Execute ("Select * from tblCustomers where UserName = '" & Request.Cookies("User")("strUserName") & "'")
rs22 = Split(RS2Name001("RS2Name"), ",")
bbb = RS2Name001("RS2Name")
For Each bbb in rs22
Response.Write rs22(x)
Response.Write "<br>"
next
Response.End

Jscript Looping
i have a jscript that accepts parameters/arguments, how do you loop thru the arguments?

i = 0;

while (!i == oArgs.length ) {
WScript.Echo[oArgs(i)];
i = i + 1;
}

this does not even get inside the loop.

Looping Through Directories
i have a subdomain on my works server that i use to store different stuff on, like different projects that i'm working on. They are all set up in their own folders, for example, sub.blah.com/project1, sub.blah.com/project2 etc etc. (all the folders have different names).

What i want to do is to create an index page on sub.blah.com that will list out all of the folders. I dont have any access to the server workings so this all has to be done with a script.

Looping Request
I have this request object and I put it in a loop but I receive an error using this, I didn't even know if I did it right

Quote: q_1=request("q_1")
q_2=request("q_2")

for i = 1 to 2

q_& i = request(q_& i) <<----syntax error

response.write q_& i
next

Looping A Record Set
I would like to know how to loop through my record set and keep it 'alive' until it reaches the end of my statements:

I am calling a SP, then based on the info in the table that I am pulling against what to loop through the rs. here is a code snippet: Code:

Looping The Db With Colum's
i have included the link of which is not working correctly (no error or anything, but table format is not what im going for) Code:

Get Last Record From Database Without Looping
how to get the last record from database without looping?

Whenever the user need to insert a new record to the database, it just
increment the id field by one from the last record.

I tried objRS.MoveLast, but it wont work.

ASPPOP3, Or Looping Arrays
I need some help with using ServerObjects ASPPOP3 Component.

At first I could not get the headers of the Message to show in the Inbox, ie. Name of Sender, Address of Sender, Subject, Message Status, etc etc
The standard information you usually get with most e-mail clients.

Now Some how I was able to show these headers in the inbox but when it has more then one message is has the same e-mail address, same subject, same everything as
the one before, so I have 5 e-mails on my server, it will show 5 e-mails, but they will all be the same. Code:

Looping A Form Post?
Basically, I have a dataset I need to send to a vendors site. They
have a page that will accept from form posts. What I'm trying to
figure out is how to loop through and submit form data when I do not
have control of the end site.

My basic idea is to have a page that will cycle through the dataset
put into invisible form fields and submit to the site (many times
over). Is this possible through asp?

Looping Through Categories In Recordsets
I have a list in a database that I have categorised using a category field. I now want to retrieve all records but grouped by categories. how do i get my asp to loop through each category creating a recordset for each one rather than hard code a new recordset for each category i would rather it did it dynamically if thats possible ??? Code:

Looping And Array Problems
I'm having problems with abit of code i'm playing with to remove html tags from a variable. I just can get it to work as im not sure how to handle the "for" statement to work with the array. Code:

Looping Through Forms Items
I have a from with four elements a checkbox and a textfield and two which are hidden. Jobid and userid.

The jobid is written once and the userid is These are dynamic items from the database.

What i want to do is loop through the items and then insert the new values back into the database via an update statement. Code:

Recordset Looping - Tables
I know how to loop around a recordset and put it into a table :

ASP Code:
<table border="1">
    <tr>
    <td>ID</td>
    <td>Answer</td>
    </tr>
    <%Do while Not answerRecordset.eof%>
            <tr align="center">
        <td><%=answerRecordset("entryName")%></td>
             </tr>
    <%  answerRecordset.MoveNext
    Loop%>
</table>

But how would i loop around but instead of one massive column put the answers into 4 diferent columns

Cyclic Looping Thru A Database
i got a SQL query here that pulls columns out from my SQLServer2K d/b and spits it out. My code fragment is as follows:

SQLCode = "SELECT * FROM BKMTABLE"

Set objRS = objConn.Execute(SQLCode)
Do While Not objRS.EOF
response.write objRS("BKM_ID") & "<br>"
response.write objRS("BKM_TITLE") & "<br>"
objRS.MoveNext
Loop
objRS.Close

Problem is, I don't want to keep on repeating response.writes for all the column headers. Is there a way to do automatic cyclic looping thru a whole table and just spit all data out including column headers?

Looping Through Tw-dimensional Array
I need to loop through a two-dimesnional array (x,y) until a value in x is empty or the end of the array is reached, whichever comes first. Example array:

Dim myArray(4,1)

myArray(0,0) = "part 1"
myArray(0,1) = quantity
myArray(1,0) = "part 2"
myArray(1,1) = quantity
myArray(2,0) = "part 3"
myArray(2,1) = quantity
myArray(3,0) = ""
myArray(3,1) = quantity
myArray(4,0) = "part 5"
myArray(4,1) = quantity

In the example above, the loop should stop once it determines myArray(3,0) is empty. If myArray(3,0) was not empty, the loop would continue until the end of the array was reached. Anybody have a code example to do this?

Looping Through Checkboxes On A Form
I want to loop through some checkboxes & extract their name & value. actually i want an if statement that says if they are empty write nothing & if they arent then extract name & value of checkbox.

i know how to do the if & extract the values etc but not the loop. at the moment i have really long code that looks at each checkbox tests if its empty & if it isnt then extracts the values I need. Code:

Build SQL String Looping
I need to build an UPDATE statement that copies the values of roughly 40 fields from a table that stores standard or default values into a table of specific contracts. There are 8 or so fields in the source table that are not in the destination table. The remaining field names are identical in both tables.

How do I create a recordset of the field names I am interested in so that I can loop through it to build my UPDATE statement?

Looping Through SQL Insert Statement
I dynamically load a question into a form along with its answer and its name (1,2,3...).
It's name is the the numeric value loaded but I ad on: Code:

Looping Through A Record Set And Summing Values
I have a record set with returns the following :-

"stringId","typeId","count"

e.g.

A, A, 3
A, B, 7
...
B, A, 19
B, B, 3
...

I can't change the query I have to work with this record set as it comes from a view which is the only DB object I can access.

I could requery the view using

SELECT SUM(count) FROM table WHERE stringId = 'x'

however this is very very slow and results in a lot of round trips to the SQL server.

What I need to do is get totals for each stringId and I am puzzling over the best way to do this in ASP.

I then need to use the totals I have calculated to work out percentages of the count column. Code:

Looping Thorough A Table To Get Code List
Assume there is a table called Item:

and fields Itemcode Customercode

now a customer may have one or many items(itemcode)

Now the issues are, Customercode can be zero or a code value.

NOw i want to put a do while loop to get all the records as comma seperated format

TempItemcodest=0
select * from Itemtable where customercode=customervalue
Do while not Rs.eof
TempItemcodest=TempItemcodest & "," & rs.fields("Itemcode")
rs.movenext
loop

TempItemcodest=TempItemcodest & "0"

so i am adding a zero at the begging and end to have the commas seperated properly.

is there any better way to do this?

Multiple Split Functions And Looping Through Them
I have the following code:

that requests both products, quantity and price from the previous page and sends to the next. Now i would want to be able to iterate through them all and run some code based on the values.

Now it works well only for the first items, then throws an error ...

ASP, Looping, And Stored Procedures. Error '800a0bb9' ...
It loops in order to get data in different, sequential date ranges. I.E. from 9/1/2000 - 10/1/2000 then 10/1/2000 - 11/1/2000 etc etc etc. It calls SPs using the 2 dates and an integer used for companyid reference.

Let's just do this for 2 SP's (there are like 6 on the page.) One SP has 3 params, one has only 2.

Now, the first iteration of the loop, it works. (because I'm response.writiting out the dates it's using to verify they are ok. The second time through I get the following error when I try to execute the following ASP: .....

Looping Through Table Data On Form.submit
I have this form..which has a table (created from stored procedure
values)..once the table is populated..i have some radio buttons (for
each row of the table) and a main submit button.

On clicking submit..i want to loop through the table..pick up the
first <TDbeing the user ID and the value of the radio button clicked
(currently I have my radio button ID set as UserID_0, UserID_1 ..
etc). And pass those into a stored procedure..

Adding Bcc
I have a form on my asp page that sends data to an emailing script. I am working with other peoples code which is causing a lot of hassle. Is there any way of sending a Bcc address command from the form rather than the emailing script?

Adding
I wanted to know how I should go about doing this. I have this query:

SQLmax="SELECT Max(OrderNumber) AS intTotal FROM Status"

Which gives the Max(OrderNumber).Say in this case it is giving out put as 37.

Now i want the output to be displayed 38,which can be done by adding 1 to Max(OrderNumber).

Should i get this by doing this way?

var=RS(intTotal)
var=var+1
Response.WRite var

Is this right?

Adding Second Value
Im using this code to pass a value to a variable:

<a href="Artists.asp?cat=<%=Server.URLEncode( rsuser( "art_Artist" ) )%>">&nbsp;<%=rsuser( "art_Artist" )%></a>

How do I add another value to this link with the variable name catArt so that I can add:

?catArt=<%=Server.URLEncode( rsuser( "art_Artist" ) )%>


Adding New Row
what do you think is the best way to implement an "add new row to table" functionalilty?
am using asp(obviously )im currently using document.createElement with javascript, but im having a hard time retrieving the data.am also thinking if this is really the best way to do this.or if this would work with all other browsers other than IE...

Adding Pwd
how to add a password to using this connection string

<%
set conn = server.createobject ("ADODB.connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("dat48372.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
SQL = "SELECT Price FROM DABRadios WHERE (ID LIKE 6)"
rs.Open SQL, conn
showall=true
%>

Adding In Asp 3.0
i have a id1 field which has data like this 002,003,004 and i have to increment it by one when i add a new customer so this is what i do

Set rs1 = Server.CreateObject("ADODB.Recordset")
sql1="Select Max(id1) from table2"
rs1.Open sql1, Conn ,2,2

maxid=rs1(0)

so i get the maxid for example as 003. the next record will be added and it should be 004 and i do it in this way maxid= maxid+1

but when the record is added the id1 field has a value of 4 instead of 004


Copyright © 2005-08 www.BigResource.com, All rights reserved