473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Procuct with decimal

Fra
Hi, I've a problem with a product between 3 input field

<form name="Form1" method="post" action="" >
<input name="lit" type="text" id="lit" disabled="disabled"/>

<input name="ore" type="text" id="ore" HIDDEN/>

<input name="qt" type="text" id="qt"/>

<input name="totale" type="text" id="totale" />

</form>

I would like to make a product

"lit*qt*ore" and write it in "totale"

but:

1) It must consider decimal number (with 2 decimal) with "," decimal symbol
(not ".")

2) To see an Alert if an user inserts a char (a,b,c,d,e...) and tranform it
in a 0 (for example) ... if user inserts "," this char wil be allowed
because I must allow decimal product
example:
lit: 1,23
qt: 2
ore: 2,50

in totale will write: 6,15
I hope you can help me!!
Jul 23 '05 #1
4 1160
Lee
Fra said:

Hi, I've a problem with a product between 3 input field

<form name="Form1" method="post" action="" >
<input name="lit" type="text" id="lit" disabled="disabled"/>

<input name="ore" type="text" id="ore" HIDDEN/>

<input name="qt" type="text" id="qt"/>

<input name="totale" type="text" id="totale" />

</form>

I would like to make a product

"lit*qt*ore" and write it in "totale"

but:

1) It must consider decimal number (with 2 decimal) with "," decimal symbol
(not ".")

2) To see an Alert if an user inserts a char (a,b,c,d,e...) and tranform it
in a 0 (for example) ... if user inserts "," this char wil be allowed
because I must allow decimal product
example:
lit: 1,23
qt: 2
ore: 2,50

in totale will write: 6,15
I hope you can help me!!


If you're going to get anything out of this assignment, you should
try your best before asking for help. Show us what you've got so
far.

Jul 23 '05 #2
JRS: In article <1M********************@news3.tin.it>, dated Sun, 17
Jul 2005 10:52:45, seen in news:comp.lang.javascript, Fra
<fr****@virgilio.it> posted :

1) It must consider decimal number (with 2 decimal) with "," decimal symbol
(not ".")
See <URL:http://www.merlyn.demon.co.uk/js-maths.htm#DPV>
2) To see an Alert if an user inserts a char (a,b,c,d,e...) and tranform it
in a 0 (for example) ... if user inserts "," this char wil be allowed
because I must allow decimal product


Consider
OK = !/[^\d,\.]/.test(F.X0.value)
if (OK) Numero = +F.X0.value ; else { Numero = 0 ; alert(0) }

and <URL:http://www.merlyn.demon.co.uk/js-valid.htm>
GENERAL : <FAQENTRY> : note that the unary + converts an empty string to
zero; that may be convenient or otherwise.

When posting the "same" article in English in comp* and in Italian in
it*, please say that you are doing so. Your request will be easier to
understand if it can be viewed in both languages, and if one sees a good
answer in either language one will not need to reply in the other.

CROSS-POSTED.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #3
Fra
I've created this

<script>
function Calc() {
var costo = parseFloat(Form1.costoTerzi.value.replace(/\,/g,'.'));
var qt = parseFloat(Form1.quantita0.value.replace(/\,/g,'.'));
var totale = (costo * qt)

document.Form1.Anno1.value = totale
}
</script>
but:

How Can I see the "," and not "." in the *
How Can I see an error message in an user inserts char "abcdefg..." and to
change the char in "0"

Thanks
Jul 23 '05 #4
JRS: In article <1H********************@news3.tin.it>, dated Tue, 19
Jul 2005 10:34:37, seen in news:it.comp.lang.javascript, Fra
<fr****@virgilio.it> posted :
var qt = parseFloat(Form1.quantita0.value.replace(/\,/g,'.')); var qt = parseFloat(Form1.quantita0.value.replace(/,/, '.'));
How Can I see the "," and not "." in the *
document.Form1.Anno1.value = String(totale).replace(/\./, ',')

document.Form1.Anno1.value = totale.toString().replace(/\./, ',')

How Can I see an error message in an user inserts char "abcdefg..." and to
change the char in "0"


Already indicated.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
19
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.