Split function and parsing for writing as hyperlink; help please


C

CompleteNewb

I'm a total newb with ASP, but I can sometimes look at code that's already
on a page and reverse engineer my way to some kind of success, but I'm
stumped on this one.

This is an ASP page that connects to a SQL2000 back end database. The
connection to the stored procedure is fine, and I am able to dim variables
and assign them field values and write them to the page (ie. MyVal =
rs("fldVal"), and then using <%=MyVal%> to show the value in the browser).

Here are the fields in question:

PartNum: the unique identifier for a stock item.

PartName: name of item.

fldCosts: multiple values separated by a comma and space. For example:

2/$5, 5/$15, 10/$35,

This means that 2 units cost $5, 5 cost $15, etc. There can be any number
of prices, and the last one in the list always has a comma after it. Keep
in mind this is one field, with multiple values inside of it separated by
commas.

fldBreak: The highest quantity currently available. For example, for the
record in question, if this field contained the number 5, then people could
only buy up to 5 of this item at a time (so they could get 2/$5 or 5/$15,
but they can't get 10/$35). There is not always a value here (when there's
no value, there's no maximum amount to order)

I have a form where people enter the partnum, then after submission the page
reloads with the partnumber, name of the item, and the price field.
However, what I need to do is take each price that's equal to or below the
limit (fldBreak), and write it as a hyperlink to add the item to our
shopping cart.

So, if we have PartNum SUV34, called Bingomat, whose fldCosts contains
1/$10, 2/$17.50, 3/$25, 4/$30.85, and whose fldBreak is 3, then the html of
the page would be:

<strong>SUV34</strong>, BingoMat: <a
href="myCart.asp?add=1/$10&PartNum=SUV34">1/$10</a> <a
href="myCart.asp?add=2/$17.50&PartNum=SUV34">2/$17.50</a> <a
href="myCart.asp?add=3/$25&PartNum=SUV34">3/$25</a>

Being able to put each hyperlinked price in its own table cell would be
great, or I could probably build a select drop-down field too. Right now,
though, I can't even get as far as writing the prices out as hyperlinks.
I've tried several combinations of Split and For/Next loops, and I feel like
I could incorporate a Do/Until using the fldBreak value if one existed, but
all of my attempts are getting errors. I think there's something about the
Split function that I'm not understanding, because I get errors just trying
to write the 1st value in the array, before I even get to the complications
of all this other stuff.

If anyone could help me with this, I would greatly, GREATLY apppreciate it.
It's the one thing standing in the way of my being able to wash my hands of
this whole cart issue.

Thanks for taking the time.

ASP Newb.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top