PDA

View Full Version : experts plz ...


scribeke
01-31-2003, 09:49 AM
I've build this script for a company, so that there clients can order products online, I'm no wiz at it so it's not that good.

Now I have a problem :

If you go to http://www.seniorensport.be/sportboetiek.shtml you'll probably won't understan anything about, it's all in dutch.

But you see a summary of products, in the first box you can enter the amount of how many of that product you want, when you blur out you get a total for the product, this works just fine, but you also get a general total in the right top, when you blur, now here's the problem I keep getting NaN in this box.

I thought, ok so something in here he see's as text instead of a number, so I've tried putting in alerts, but I just can't seem to find what's wrong, I hope somebody can help me ...

kdjoergensen
01-31-2003, 02:48 PM
function count(naam,val,tot,prijs)
{
var val1 = val.value;
var test = val1.indexOf("-");
var test2 = val1.indexOf(",");
var test3 = val1.indexOf(".");
if (test == -1 && test2 == -1 && test3 == -1)
{
var totaal = val1 * prijs;
tot.value = totaal;
}
else
{
alert('Deze waarde is niet toegelaten');
val.value="";
tot.value="";
}
}


Try this:

function count(naam,val,tot,prijs)
{
var val1 = val.value;
var test = val1.indexOf("-");
var test2 = val1.indexOf(",");
var test3 = val1.indexOf(".");
if (test == -1 && test2 == -1 && test3 == -1)
{
val1 = Number(val1);
var totaal = val1 * prijs;
tot.value = totaal;
}
else
{
alert('Deze waarde is niet toegelaten');
val.value="";
tot.value="";
}
}


The line is this: val1 = Number(val1);

scribeke
02-01-2003, 05:07 AM
Nope still nothing, thanks for replying though, I've putted an alert for the new line and behing the new line and they both return a number for val1 so I don't think that's the problem ...