webForumDet fria alternativet

Ta fram det lägsta priset

ASP

25 svar · 1 092 visningar · startad av devotion

Medlem sedan jan. 20013 582 inlägg
Frågan#1

:)

Hmm, har en fråga!

Jag har följande kod, Tack emission... :birp

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sSQL, objConn, 3, 1

set sSuppliers=CreateObject("Scripting.Dictionary")
set sArticles=CreateObject("Scripting.Dictionary")
set sSupplierArticles=CreateObject("Scripting.Dictionary")

Do while not objRS.EOF

	sSuppliers(cstr(objRS("SupplierId"))) = cstr(objRS("SupplierName"))		
	sArticles(cstr(objRS("articleName"))) = cstr(objRS("articleUnit"))
	sKey=cstr(objRS("SupplierId")) & vbTab & cstr(objRS("articleName"))
	
	if not sSupplierarticles.Exists(sKey) then
		set sSupplierArticles(sKey)=CreateObject("Scripting.Dictionary")
	end if
	sSupplierArticles(sKey)(cstr(objRS("articleNumber")))=Array(cdbl(objRS("articlePrice")),cstr(objRS("CategoryName")))
	objRs.MoveNext
	
Loop	

response.write "<table><thead><tr><th>Artikelbenämning</th><th>Enhet</th>"

	for each iSupplierId in sSuppliers
		response.write "<th>" & sSuppliers(iSupplierId) & "</th>"
	next

	response.write "</tr></thead><tbody>"

	for each sArticle in sArticles
		response.write "<tr><td>" & sArticle & "</td><td>" & sArticles(sArticle) & "</td>"
		for each iSupplierId in sSuppliers
			response.write "<td>" 
			sKey=iSupplierId & vbTab & sArticle
			if not sSupplierArticles.Exists(sKey) then
				response.write "&nbsp;"
			else
				response.write "<div id='result'><ul>" 
				for each sSupplierarticle in sSupplierarticles(sKey)
					i = i+1
				 	if i = 1 then
					  'detta är det lägsta priset, spara undan i en variabel
					  dLowestArticlePrice = cdbl(sSupplierarticles(sKey)(sSupplierarticle)(0))
					  sFirstArticleNumber = sSupplierarticle
				 	end if
					dArticlePrice = cdbl(sSupplierarticles(sKey)(sSupplierarticle)(0))
					sArticleNumber = sSupplierarticle
					sArticleCategory = sSupplierarticles(sKey)(sSupplierarticle)(1)
					
					Response.Write "<li><span onclick=""changeValue('" & sArticleNumber & "','" & dArticlePrice & "','" & sArticleCategory & "','articleNumber')"" style=""cursor:pointer;color:blue""></span></li>"
					
				next
				Response.write "</ul></div>"
			end if
			response.write "<a href="""" onclick=""return showResults(event,this)"" style=""color:blue;text-decoration:none"">" & sFirstArticleNumber & " - " & dLowestArticlePrice & " kr</a><input type=""hidden"" name=""articleNumber"" value=""" & sFirstArticleNumber & """>"
			response.write "</td>"
		next
		response.write "</tr>"
	next

response.write "</tbody></table>"

objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing

set sSuppliers = Nothing
set sArticles = Nothing
set sSupplierArticles = Nothing

Jag vill få fram den första posten, dvs det lägsta priset på en artikel, men när jag gör som i ovanstående kod, så blir det det lägsta priset oberoende av leverantör.... Och det blir ju lite fel... Vad gör jag för fel?

Resultat:
http://80.73.182.130/testscript/cart_test.asp

Mvh
Henrik

Medlem sedan dec. 19996 721 inlägg
#2

devotion skrev:

så blir det det lägsta priset oberoende av leverantör....

Snarare tvärtom väl?

Nåväl, här kommer en rejält omskriven version, med klasser i stället för arrayen som databärare. Mest i utbildningssyfte...

En trevlig bonuseffekt är att du inte behöver söka ut artiklarna i någon speciell ordning. Det lägsta priset uppfattas ändå.

Den kan kräva en del fix, för jag har ingen möjlighet att testa.

Class Article
	Public Name
	Public Unit
	Public CheapestSupplierArticle
End Class

Class SupplierArticle
	Public Article
	Public ArticleNumber
	Public CategoryName
	Public Price
	Public Supplier
End Class

Class Supplier
	Public Name
	Public Id
End Class

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sSQL, objConn, 3, 1

set sSuppliers=CreateObject("Scripting.Dictionary")
set sArticles=CreateObject("Scripting.Dictionary")
set sSupplierArticles=CreateObject("Scripting.Dictionary")

Do while not objRS.EOF
	supplierId=cstr(objRS("SupplierId"))
	supplierName=cstr(objRS("SupplierName"))
	articleName  =cstr(objRS("articleName"))
	articleUnit=cstr(objRS("articleUnit"))
	articlePrice=cdbl(objRS("articlePrice"))
	categoryName=cstr(objRS("CategoryName"))
	sSuppliers(supplierId) = supplierName
	articleNumber=cstr(objRS("articleNumber"))
	
	if not sSuppliers.Exists(supplierId) then
		set oSupplier = new Supplier
		oSupplier.Name = supplierName
		oSupplier.Id = supplierId
		set sSuppliers(supplierId)=oSupplier
	else
		set oSupplier = sSuppliers(supplierId)
	end if
	
	if not sArticles.Exists(articleName) then
		set oArticle=new Article
		oArticle.Name=articleName
		oArticle.Unit=articleUnit
		set oArticle.CheapestSupplierArticle=Nothing
		set sArticles(articleName) = oArticle
	else
		set oArticle=sArticles(articleName)
	end if
	
	sKey=supplierId & vbTab & articleName
	
	if not sSupplierarticles.Exists(sKey) then
		set sSupplierArticles(sKey)=CreateObject("Scripting.Dictionary")
	end if

	set oSupplierArticle=new SupplierArticle

	set sSupplierArticles(sKey)(articleNumber)=oSupplierArticle
	
	set oSupplierArticle.Article=oArticle
	set oSupplierArticle.Supplier=oSupplier
	
	oSupplierArticle.ArticleNumber=articleNumber
	oSupplierArticle.CategoryName=categoryName
	oSupplierArticle.Price=articlePrice

	'Ser man på! En billigare version!
	if oArticle.CheapestSupplierArticle is Nothing then
		set oArticle.CheapestSupplierArticle=oSupplierArticle
	elseif oArticle.CheapestSupplierArticle.Price>oSupplierArticle.Price then
		set oArticle.CheapestSupplierArticle=oSupplierArticle
	end if

	objRs.MoveNext
	
Loop	

response.write "<table><thead><tr><th>Artikelbenämning</th><th>Enhet</th>"

	for each iSupplierId in sSuppliers
		set oSupplier=sSuppliers(iSupplierId)
		response.write "<th>" & oSupplier.Name & "</th>"
	next

	response.write "</tr></thead><tbody>"

	for each sArticle in sArticles
		set oArticle=sArticles(sArticle)
		response.write "<tr><td>" & sArticle & "</td><td>" & oArticle.Unit & "</td>"
		for each iSupplierId in sSuppliers
			set oSupplier=sSuppliers(iSupplierId)
			response.write "<td>" 
			sKey=iSupplierId & vbTab & sArticle
			if not sSupplierArticles.Exists(sKey) then
				response.write "&nbsp;"
			else
				response.write "<div id='result'><ul>" 
				for each sSupplierarticle in sSupplierarticles(sKey)
					set oSupplierarticle=sSupplierarticles(sKey)(sSupplierarticle)
					
					Response.Write "<li><span onclick=""changeValue('" & oSupplierArticle.ArticleNumber & "','" & oSupplierArticle.Price & "','" & oSupplierArticle.CategoryName & "','articleNumber')"" style=""cursor:pointer;color:blue""></span></li>"
					
				next
				Response.write "</ul></div>"
			end if
			response.write "<a href="""" onclick=""return showResults(event,this)"" style=""color:blue;text-decoration:none"">" & oArticle.CheapestSupplierArticle.ArticleNumber & " - " & oArticle.CheapestSupplierArticle.Price & " kr</a><input type=""hidden"" name=""articleNumber"" value=""" & oArticle.CheapestSupplierArticle.ArticleNumber & """>"
			response.write "</td>"
		next
		response.write "</tr>"
	next

response.write "</tbody></table>"

objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing

set sSuppliers = Nothing
set sArticles = Nothing
set sSupplierArticles = Nothing
Medlem sedan jan. 20013 582 inlägg
#3

Snarare tvärtom väl?

Ja, givetvis.... :r

Men, vad fint det ser ut... Man kan väl säga att det är betydligt över min förmåga......

Har testat lite på morgonen och får följande fel:

Feltyp:
Körningsfel i Microsoft VBScript (0x800A01A8)
Objekt krävs.: '[string: "Elektroskandia"]'
/articles/cart.asp, line 74

rad 74:

		set oSupplier = sSuppliers(supplierId)

mvh
Henrik

Medlem sedan dec. 19996 721 inlägg
#4

Ta bort raden

"sSuppliers(supplierId) = supplierName"

Den råkade bli kvar

Medlem sedan jan. 20013 582 inlägg
#5

Funkish!

Ska jag vara ärlig så undrade jag vad den raden gjorde där... Men jag ifrågasätter inte mästaren!

Tack som fan!
Mvh
Henrik

Ps.. Bara resten kvar... ;)

Medlem sedan jan. 20013 582 inlägg
#6

hmmm...

Det blir inte helt bra:

http://80.73.182.130/articles/cart.asp

Bifaogar en dump...

Mvh
Henrik

cart.jpg
Medlem sedan dec. 19996 721 inlägg
#7

Berätta

Medlem sedan jan. 20013 582 inlägg
#8

Jo, det är ju endast det totalt sett lägsta priset som visas hos alla leverantörer... Bilden jag skickade med visar vilken information som finns om artikeln: EKKJ 1X10/10. Den har ju ett lägsta pris på 122 kr. Det är detta pris som visas hos alla leverantörer... Det skall ju vara leverantörens artikel med det lägsta priset som visas...

Mvh
Henrik

Medlem sedan jan. 20013 582 inlägg
#9

Tror du det går att lösa?

Hade en tanke att lägga till ett fält i tblCart

defaultArticle

datatyp bit...
Om den är null ska det lägsta priset visas som default om den däremot är "ikryssad" ska den artikeln visas. Det kan ju finnas tillfällen då man inte vill jämföra med det billigaste utan vill ha en dyrare, och kanske bättre, vara...

Edit//Se nedan!
Mvh
Henrik

Medlem sedan jan. 20013 582 inlägg
#10

Gjorde en tabell till istället...

tblDefaultArticle
*supplierId
*userId
*defaultArticleNumber
*defaultArticle (bit)

Så nu ser SQL-frågan ut så här:

sSQL = 	"SELECT tblArticle.articleName, tblArticle.articleUnit, tblPrice.articlePrice, tblSupplier.SupplierName, " &_
	"tblCart.articleAmount, tblSupplier.SupplierId, tblCategory.CategoryName, tblPrice.articleNumber, tblDefaultArticle.defaultArticle " &_
	"FROM tblArticle " &_
	"INNER JOIN tblPrice ON tblArticle.articlenumber = tblPrice.articleNumber " &_
	"INNER JOIN tblSupplier ON tblPrice.articleSupplierId = tblSupplier.SupplierId " &_
	"INNER JOIN tblCart ON tblArticle.articleName = tblCart.articleName " &_
	"INNER JOIN tblCategory ON tblPrice.articleSupplierId = tblCategory.supplierId AND tblPrice.articleCategoryNumber = tblCategory.categoryNumber " &_
	"LEFT OUTER JOIN tblDefaultArticle ON tblPrice.articleSupplierId = tblDefaultArticle.supplierId AND tblPrice.articleNumber = tblDefaultArticle.defaultArticleNumber "&_
	"ORDER BY tblPrice.articlePrice"

Är ingen artikel vald som default är det Null annars 1

Mvh
Henrik

Medlem sedan dec. 19996 721 inlägg
#11

Det går att lösa, men nu måste jag nanna. Kan ta tag i det på lördag.

Medlem sedan jan. 20013 582 inlägg
#12

Coolt! :)

Words like violence
Break the silence

;)

Mvh
Henrik

Medlem sedan jan. 20013 582 inlägg
#13

Hej igen!

Nu blir resultatet så här:
http://80.73.182.130/articles/cart.asp

Och det ser ju fint ut...

Det som dock inte stämmer är att det är det lägsta priset totalt sett som visas...

Mvh
Henrik

Medlem sedan dec. 19996 721 inlägg
#14
Class Product
	Public Name
	Public Unit
End Class

Class SupplierProduct
	Public Product
	Public CheapestArticle
	Public Supplier
	Public Articles
	Private Sub Class_Initialize
		Set Articles=CreateObject("Scripting.Dictionary")
		Set CheapestArticle=Nothing
	End Sub
End Class

Class SupplierArticle
	Public SupplierProduct
	Public ArticleNumber
	Public CategoryName
	Public Price
End Class

Class Supplier
	Public Name
	Public Id
End Class

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sSQL, objConn, 3, 1

set sSuppliers=CreateObject("Scripting.Dictionary")
set sProducts = CreateObject("Scripting.Dictionary")
set sSupplierProducts=CreateObject("Scripting.Dictionary")

Do while not objRS.EOF
	supplierId=cstr(objRS("SupplierId"))
	supplierName=cstr(objRS("SupplierName"))
	articleName  =cstr(objRS("articleName"))
	articleUnit=cstr(objRS("articleUnit"))
	articlePrice=cdbl(objRS("articlePrice"))
	categoryName=cstr(objRS("CategoryName"))
	articleNumber=cstr(objRS("articleNumber"))
	
	if not sSuppliers.Exists(supplierId) then
		set oSupplier = new Supplier
		oSupplier.Name = supplierName
		oSupplier.Id = supplierId
		set sSuppliers(supplierId)=oSupplier
	else
		set oSupplier = sSuppliers(supplierId)
	end if
	
	if not sProducts.Exists(articleName) then
		set oProduct = new Article
		oProduct.Name=articleName
		oProduct.Unit=articleUnit
		set sProducts(articleName) = oProduct
	else
		set oProduct=sProducts(articleName)
	end if
	
	sKey=supplierId & vbTab & articleName
	
	if not sSupplierProducts.Exists(sKey) then
		set oSupplierProduct=new SupplierProduct
		set oSupplierProduct.Product=oProduct
		set oSupplierProduct.Supplier=oSupplier
		set sSupplierProducts(sKey)=oSupplierProduct
	else
		set oSupplierProduct=sSupplierProducts(sKey)
	end if
	
	set oSupplierArticle=new SupplierArticle
	set oSupplierArticle.SupplierProduct=oSupplierProduct
	oSupplierArticle.ArticleNumber=articleNumber
	oSupplierArticle.CategoryName=categoryName
	oSupplierArticle.Price=articlePrice

	if oSupplierProduct.CheapestArticle is nothing then
		set oSupplierProduct.CheapestArticle=oSupplierArticle
	else if oSupplierProduct.CheapestArticle.Price>oSupplierArticle.Price then
		set oSupplierProduct.CheapestArticle=oSupplierArticle
	end if

	oSupplierProduct.Articles(articleNumber)=oSupplierArticle

	objRs.MoveNext
	
Loop	

response.write "<table><thead><tr><th>Artikelbenämning</th><th>Enhet</th>"

	for each iSupplierId in sSuppliers
		set oSupplier=sSuppliers(iSupplierId)
		response.write "<th>" & oSupplier.Name & "</th>"
	next

	response.write "</tr></thead><tbody>"

	for each sArticleName in sProducts
		set oProduct=sProducts(sArticleName)
		response.write "<tr><td>" & sArticleName & "</td><td>" & oProduct.Unit & "</td>"
		for each iSupplierId in sSuppliers
			set oSupplier=sSuppliers(iSupplierId)
			response.write "<td>" 
			sKey=iSupplierId & vbTab & sArticleName
			if not sSupplierProducts.Exists(sKey) then
				response.write "&nbsp;"
			else
				set oSupplierProduct=sSupplierProducts(sKey)
				response.write "<div id='result'><ul>" 
				for each sSupplierarticle in oSupplierProduct.Articles
					set oSupplierarticle=oSupplierProduct.Articles(sSupplierarticle)
					
					Response.Write "<li><span onclick=""changeValue('" & oSupplierArticle.ArticleNumber & "','" & oSupplierArticle.Price & "','" & oSupplierArticle.CategoryName & "','articleNumber')"" style=""cursor:pointer;color:blue""></span></li>"
					
				next
				Response.write "</ul></div>"
				response.write "<a href="""" onclick=""return showResults(event,this)"" style=""color:blue;text-decoration:none"">" & oSupplierProduct.CheapestArticle.ArticleNumber & " - " & oSupplierProduct.CheapestArticle.Price & " kr</a><input type=""hidden"" name=""articleNumber"" value=""" & oSupplierProduct.CheapestArticle.ArticleNumber & """>"
			end if
			response.write "</td>"
		next
		response.write "</tr>"
	next

response.write "</tbody></table>"

objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing

set sSuppliers = Nothing
set sArticles = Nothing
set sSupplierArticles = Nothing

Säkert med en del fel, men det kan vara en utgångspunkt.

Medlem sedan jan. 20013 582 inlägg
#15

Hej! :)
Tar denna koden hänsyn till om en annan artikel än den lägsta är vald som default enligt:
http://www.webforum.nu/showthread.php?p=1200358#post1200358

Har inte riktigt fått igång det än men jag provar och försöker!

Tack för all hjälp; emission! :)

Mvh
Henrik

Medlem sedan jan. 20013 582 inlägg
#16

Hmmm, jag får detta felet..:

Feltyp:
Kompileringsfel i Microsoft VBScript (0x800A040E)
'loop' utan 'do'
/testscript/cart_2.asp, line 184
Loop

Jag tycker dock det ser rätt ut.... (mend et är det ju inte eftersom jag får ett felmeddelande.. ;)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% 'Option Explicit %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
var prevElm;
function showResults(e,a)
{
  var left, top;
  if (window.event){
    left = window.event.clientX;
    top  = window.event.clientY;
  } else if (e){
    left = e.pageX;
    top  = e.pageY;
  }

  if (left && top){
	if (prevElm)
		prevElm.style.visibility = "hidden";
    window["a"] = a;
    elm.style.left = left + "px";
    elm.style.top  = top + "px";
    elm.style.visibility = "visible";
  }

  return false;
}

function chooseResultContainer(id) 
{
  prevElm = window["elm"];
  window["elm"] = document.getElementById(id);
}

document.onclick = function(e)
{
  var tmp = window.event ? window.event.srcElement : e ? e.target : 0,
      fnd = false;
  if (tmp){
    while (tmp){
      if (tmp == elm || (typeof a != "undefined" && tmp == a)) {
        fnd = true;
        break;
      }
      tmp = tmp.parentNode;
    }
  }

  if (!fnd) elm.style.visibility = "hidden";
}

function changeValue(p,c,s,i,linkid)
{
  if (a && elm){
    a.innerHTML = p + " - " + c + " kr";
    document.forms[0].elements[i].value = c;
    elm.style.visibility="hidden";
    document.getElementById('link'+linkid).title=s;
    document.getElementById('link'+linkid).style.color="pink";
  }
}

</script>

<link href="../css/cart.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
'Deklarera variabler
'*******************
Dim objConn, objRS, objDict, sSQL, sSuppliers, sSupplierArticles, sArticles, sKey, iSupplierId, sArticle, sSupplierarticle

iResultCount = 0

' Öppna databasen
' ***************
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = Application("sConn")
objConn.Open

sSQL = 	"SELECT tblArticle.articleName, tblArticle.articleUnit, tblPrice.articlePrice, tblSupplier.SupplierName, " &_
		"tblCart.articleAmount, tblSupplier.SupplierId, tblCategory.CategoryName, tblPrice.articleNumber, tblDefaultArticle.defaultArticle " &_
		"FROM tblArticle " &_
		"INNER JOIN tblPrice ON tblArticle.articlenumber = tblPrice.articleNumber " &_
		"INNER JOIN tblSupplier ON tblPrice.articleSupplierId = tblSupplier.SupplierId " &_
		"INNER JOIN tblCart ON tblArticle.articleName = tblCart.articleName " &_
		"INNER JOIN tblCategory ON tblPrice.articleSupplierId = tblCategory.supplierId AND tblPrice.articleCategoryNumber = tblCategory.categoryNumber " &_
		"LEFT OUTER JOIN tblDefaultArticle ON tblPrice.articleSupplierId = tblDefaultArticle.supplierId AND tblPrice.articleNumber = tblDefaultArticle.defaultArticleNumber "&_
		"ORDER BY tblPrice.articlePrice"
Class Product
	Public Name
	Public Unit
End Class

Class SupplierProduct
	Public Product
	Public CheapestArticle
	Public Supplier
	Public Articles
	Private Sub Class_Initialize
		Set Articles=CreateObject("Scripting.Dictionary")
		Set CheapestArticle=Nothing
	End Sub
End Class

Class SupplierArticle
	Public SupplierProduct
	Public ArticleNumber
	Public CategoryName
	Public Price
End Class

Class Supplier
	Public Name
	Public Id
End Class

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sSQL, objConn, 3, 1

set sSuppliers=CreateObject("Scripting.Dictionary")
set sProducts = CreateObject("Scripting.Dictionary")
set sSupplierProducts=CreateObject("Scripting.Dictionary")

Do while not objRS.EOF
	supplierId=cstr(objRS("SupplierId"))
	supplierName=cstr(objRS("SupplierName"))
	articleName  =cstr(objRS("articleName"))
	articleUnit=cstr(objRS("articleUnit"))
	articlePrice=cdbl(objRS("articlePrice"))
	categoryName=cstr(objRS("CategoryName"))
	articleNumber=cstr(objRS("articleNumber"))
	
	if not sSuppliers.Exists(supplierId) then
		set oSupplier = new Supplier
		oSupplier.Name = supplierName
		oSupplier.Id = supplierId
		set sSuppliers(supplierId)=oSupplier
	else
		set oSupplier = sSuppliers(supplierId)
	end if
	
	if not sProducts.Exists(articleName) then
		set oProduct = new Article
		oProduct.Name=articleName
		oProduct.Unit=articleUnit
		set sProducts(articleName) = oProduct
	else
		set oProduct=sProducts(articleName)
	end if
	
	sKey=supplierId & vbTab & articleName
	
	if not sSupplierProducts.Exists(sKey) then
		set oSupplierProduct=new SupplierProduct
		set oSupplierProduct.Product=oProduct
		set oSupplierProduct.Supplier=oSupplier
		set sSupplierProducts(sKey)=oSupplierProduct
	else
		set oSupplierProduct=sSupplierProducts(sKey)
	end if
	
	set oSupplierArticle=new SupplierArticle
	set oSupplierArticle.SupplierProduct=oSupplierProduct
	oSupplierArticle.ArticleNumber=articleNumber
	oSupplierArticle.CategoryName=categoryName
	oSupplierArticle.Price=articlePrice

	if oSupplierProduct.CheapestArticle is nothing then
		set oSupplierProduct.CheapestArticle=oSupplierArticle
	else if oSupplierProduct.CheapestArticle.Price>oSupplierArticle.Price then
		set oSupplierProduct.CheapestArticle=oSupplierArticle
	end if

	oSupplierProduct.Articles(articleNumber)=oSupplierArticle

	objRs.MoveNext
	
[B]Rad 184---> Loop	[/B]

response.write "<table><thead><tr><th>Artikelbenämning</th><th>Enhet</th>"

	for each iSupplierId in sSuppliers
		set oSupplier=sSuppliers(iSupplierId)
		response.write "<th>" & oSupplier.Name & "</th>"
	next

	response.write "</tr></thead><tbody>"

	for each sArticleName in sProducts
		set oProduct=sProducts(sArticleName)
		response.write "<tr><td>" & sArticleName & "</td><td>" & oProduct.Unit & "</td>"
		for each iSupplierId in sSuppliers
			set oSupplier=sSuppliers(iSupplierId)
			response.write "<td>" 
			sKey=iSupplierId & vbTab & sArticleName
			if not sSupplierProducts.Exists(sKey) then
				response.write "&nbsp;"
			else
				set oSupplierProduct=sSupplierProducts(sKey)
				response.write "<div id='result'><ul>" 
				for each sSupplierarticle in oSupplierProduct.Articles
					set oSupplierarticle=oSupplierProduct.Articles(sSupplierarticle)  
					
					Response.Write "<li><span onclick=""changeValue('" & oSupplierArticle.ArticleNumber & "','" & oSupplierArticle.Price & "','" & oSupplierArticle.CategoryName & "','articleNumber')"" style=""cursor:pointer;color:blue""></span></li>"
					
				next
				Response.write "</ul></div>"
				response.write "<a href="""" onclick=""return showResults(event,this)"" style=""color:blue;text-decoration:none"">" & oSupplierProduct.CheapestArticle.ArticleNumber & " - " & oSupplierProduct.CheapestArticle.Price & " kr</a><input type=""hidden"" name=""articleNumber"" value=""" & oSupplierProduct.CheapestArticle.ArticleNumber & """>"
			end if
			response.write "</td>"
		next
		response.write "</tr>"
	next

response.write "</tbody></table>"

objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing

set sSuppliers = Nothing
set sArticles = Nothing
set sSupplierArticles = Nothing
%>
</body>
</html>

Mvh
Henrik

Medlem sedan juni 200032 967 inlägg
#17
	[b]else if[/b] oSupplierProduct.CheapestArticle.Price...
	[b]elseif[/b] oSupplierProduct.CheapestArticle.Price...
Medlem sedan jan. 20013 582 inlägg
#18

Aha!

Det kund eman ju nästan sett själv.. :(

Tack schnabeln!

Nu kom det dock ett annat fel..

Körningsfel i Microsoft VBScript (0x800A01FA)
Klass har inte definierats: 'Article'
/testscript/cart_2.asp, line 149

Testar och letar vidare ... :)

Mvh
Henrik

Medlem sedan juni 200032 967 inlägg
#19

Det ska inte vara "New Product" då, eftersom det är det emission (dvs du) kallat klassen?

Medlem sedan jan. 20013 582 inlägg
#20

Aha!

Classen Article var definierad som product... Ändrade till Article

Class product
	Public Name
	Public Unit
End Class

till

Class Article
	Public Name
	Public Unit
End Class

till

då fick jag istället följande fel:

Feltyp:
Körningsfel i Microsoft VBScript (0x800A01B6)
Objektet stöder inte egenskapen eller metoden.
/testscript/cart_2.asp, line 181

det berodde på att

oSupplierProduct.Articles(articleNumber)=oSupplierArticle

skulle ändras till:

set oSupplierProduct.Articles(articleNumber)=oSupplierArticle

så nu verkar det funka fint tror jag... tets och provar mer! ... :)

Då skulle man bara fått in det där emd default artticle oxå..... ;)

Mvh
Henrik

269 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
118 ms — deklarationer (db)
0 ms — hämta statistik (cache)
147 ms — hämta tråd, inlägg och bilagor (db)
119 ms — ändringar (db)