Fantastic fantastic!!!
You are a magician with javascript :-) :-) :-)
That did the trick, now the rest is easy solvable!
If you're ever going to norway, I'll buy you a beer ;-)
It won't work to put the function inside the loop, it just takes one costprice and using that for all the SKUs.
To get this to work, I need to get the function to read this value somehow.
What if i put this function inside the loop, maybe this will help, because then I might get the costprice like this:
function UpdateDG(what) {
c = parseFloat(what.value)/<%=costprice%>;
d = (c*100)-100;
what.form[what.name+'_a'].value = Math.round(d*100)/100 + "%";
}
It comes from the database, this is a "Do while not end of file" - "loop" thing, and the costprice is getable for each loop by the name "kostpris".
(I think I dont need to translate that word ;) )
If refering to "kostpris" like this:
<input type=hidden name=kostpris value="&kostpris&">
it would...
Wow that was it! It was the name starting with a number :-)
But one issue solved, now I see another comming, is there any way to post the cost-price to this function as well?
Here are the code, slightly changed so you don't need to see all TDs in the table.
The database connection is also removed, since this works :-)
The Javascript function starts at line 17, and the input section starts at line 43.
Sub ShowUnitsInCat
ShowUpperMenu()
''databaseconnection+++...
onkeyup worked perfect on my "test.html".
But I still can't get this to work in my real project, is there any easy way to write variables to the screen?
maybe alert or something?
Because in my project, the percentage shows nothing when entering data in the priceX field.
I'm sorry, but I can't see the difference between what I posted last post, and what you posted to me ;-)
Here are the source-code from IE when trying to show SKU number 36422
<input name='36422_1' type=text size=5 onkeydown='UpdateDG(this);'>
<input name='36422_1_a' type=text size=3...
Yes, now the example file works :-) But I still don't get this to work in my project.
We have 3 different prices on our SKUs, If a SKUnumber is 34343, the first price is 34343_1, second is 34343_2 and last is 34343_3.
The percentage field is 34343_1_a for the first price, 34343_2_a for the...
Sorry, my mistake.
Here are the file (- the sql part) showing how I have done it.
I have 6 "SKUs" here, and I have added functions for the 3 first SKUs.
<h1>Price</h1>
<form name=form>
<script type='text/javascript'>
function UpdateDG1() {
c = this.form.price1.value/123;
d =...
I had to do this for each line. I have hard-coded the cost-price (as 123), and experimentet a bit with onkeydown, onchange +++
<form name=form>
<script type='text/javascript'>
function UpdateDG() {
c = this.form.price.value/123;
d = (c*100)-100; this.form.percentage.value =...
Hi!
This is my first post here. I'm new to javascript, but have done a lot of html/asp programming. If I post this on the wrong forum, I'm sorry.
My case is like this:
I'm making a pricing tool for our intraweb. This tool gets our SKUs from an sql-server.
I then have the cost for all SKUs, and...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.