473,505 Members | 14,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javaScript question

I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line
7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }

Jul 19 '05 #1
9 1188
This isn't the right group for javascript issues. .scripting.jscript is a
decent one for such questions.

Ray at work

"Scott" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line
7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }

Jul 19 '05 #2
hi,
why don't you make this:
if(i == lst.options.length)
{
actionX;
actionJJHJ;
or break the for loop, thus:
break;
}
I hope that helps you.

--

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
"Scott" <an*******@discussions.microsoft.com> escreveu na mensagem
news:03****************************@phx.gbl...
I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line
7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }

Jul 19 '05 #3
after the loop, trim off the last character.....

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Scott" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line
7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }

Jul 19 '05 #4

I have to sort of 50/50 disagree with you Ray.

This is an ASP group which can be both coded in VBscipt & javascript,
because most people code in VBscript thats what we see the most here.

But I do agree that the other group would get a better response
because more people in that group will know javascript more than the
people in this group.

I myself am currently learning Jscript/Javascript and will post
questions in the other group about problems in that language more.

This is not a knock at you as I've seen alot of your posts and your
very helpful (even to me in the past :))

Al
On Tue, 13 Jan 2004 15:05:10 -0500, "Ray at <%=sLocation%>"
<myfirstname at lane34 dot com> wrote:
This isn't the right group for javascript issues. .scripting.jscript is a
decent one for such questions.

Ray at work

"Scott" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line
7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }


Jul 19 '05 #5

oops, just noticed he's using client side code, so yes the other group
will be better as ASP is a serverside group.

Al.
On Tue, 13 Jan 2004 15:05:10 -0500, "Ray at <%=sLocation%>"
<myfirstname at lane34 dot com> wrote:
This isn't the right group for javascript issues. .scripting.jscript is a
decent one for such questions.

Ray at work

"Scott" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line
7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }


Jul 19 '05 #6
I wish there were more <%@ language=jscript %> posts. I use vbscript, but I
like to look at jscript code more for some reason. :]

Ray at home

"Harag" <ha***@REMOVETHESECAPITALSsofthome.net> wrote in message
news:54********************************@4ax.com...

oops, just noticed he's using client side code, so yes the other group
will be better as ASP is a serverside group.

Al.

Jul 19 '05 #7

lol, well you can look at mine all the time if you wish, I just
converted over to Jscript ASP and learning more every day... I've now
started posting in

comp.lang.javascript
ms.public.scipting.jscript

I needed to learn how to do client side coding and since javascript is
the choice language for that I thought I'd best learn it so I can code
it from scratch rather than find other peoples and "play" with it. So
I'm now coding in Jscript server-side where possible.

Al.
On Tue, 13 Jan 2004 20:54:08 -0500, "Ray at <%=sLocation%>"
<myFirstNameATlane34dotKOMM> wrote:
I wish there were more <%@ language=jscript %> posts. I use vbscript, but I
like to look at jscript code more for some reason. :]

Ray at home

"Harag" <ha***@REMOVETHESECAPITALSsofthome.net> wrote in message
news:54********************************@4ax.com.. .

oops, just noticed he's using client side code, so yes the other group
will be better as ASP is a serverside group.

Al.


Jul 19 '05 #8
"Ray at <%=sLocation%>" wrote:

I wish there were more <%@ language=jscript %> posts. I
use vbscript, but I like to look at jscript code more
for some reason. :]


I, for one, make every effort to respond with JScript and VBScript solutions
when I post in here. We're 100% JScript over here, FWIW.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #9
Hi,

You would need to add one more if statement around line 7
that checks to see if your loop variable (i) is at the
last item you are checking.

Try:
if(i<lst.options.length){
lstRecipients += ",";
}

That should work fine.
-----Original Message-----
I have the following function below in my ASP that I am
having a problem with, because I'm not that familiar with
javaScript. What I want to know is how can I tell that I
am at the end of my For-Loop, so I can prevent an extra
comma from being appended to lstRescipients variable (line7)?

1 function getRecipients(){
2 var lstRecipients = "";
3 var lst = document.getElementById
("lstEmails");
4 for(var i=0;i<lst.options.length;i++){
5 //if (lst.options[i].selected){
6 lstRecipients +=
lst.options[i].value;
7 lstRecipients += ",";
8 //alert(i);
9 //alert(lstRecipients);
10 //}
11 }
12 return lstRecipients;
13 }

.

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.