jQuery Loop

I have a pices of jQuery that loops and adds up a price.  However, I don't have it working 100%.  The loop if the total does not equal 100 Than I make it 100.  BUT the following iterations don't matter. I have the following:
if (item_count == 1) {
 		if(premium_total < 100) {
			premium_total = 100;
		} else {
			premium_total = premium_total;

Open in new window

But instead of item_count, I need it to be (If this is the first time looping)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David SankovskySenior SysAdminCommented:
Did you try a Do while?

Do while means First run the loop, Then check the condition
Meaning you will ALWAYS enter the loop at least once.

though if I understand you correctly, you need to start looping when premium_total = 100.
So why don't you just.. Set it first, and then start looping? Or Am I getting the point wrong?
rgranlundAuthor Commented:
The loop always runs once but then on other occasions it will run more than once.  I need to make sure the first time it runs, it meets 100, the other times it loops it does not need to check for this.  The reason it is not "Just Set", is because there are about 50 factors being taken into consideration.
David SankovskySenior SysAdminCommented:
You could use a boolean flag :
as in
{ if (<100)....

but that's pretty much what you've been doing with an integer.

I don't see another way of going around this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
I don't see a loop in the code
Can you post the full code so we can see what you are trying to do.
rgranlundAuthor Commented:
This was not the solution, however, I got me going in the correct direction to solve the issue.  What I ended up using was the {row_id}
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.