473,598 Members | 3,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what's the vbscript's cint() function in javascript

amy
I have the following function to get the total qty:

function calttl()
{
var ttlqty
ttlqty=0
for (i = 0; i <= document.qtymai n.orderdetail.l ength-1; i++)
{
ttlqty = ttlqty + document.qtymai n.qty.item(i).v alue
}

}

The problem I have is the document.qtymai n.qty.item(i).v alue I get
look like a string, so the number I get for ttlqty is not add up the
number but concatenate.

How do I convert the value I get to a number in javascript?

Thanks for any help in advance.

Amy
Jul 20 '05 #1
8 19171
aj***@elario.co m (amy) writes:
The problem I have is the document.qtymai n.qty.item(i).v alue I get
look like a string, so the number I get for ttlqty is not add up the
number but concatenate.


<URL:http://jibbering.com/faq/#FAQ4_21>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
amy wrote on 16 okt 2003 in comp.lang.javas cript:
ttlqty = ttlqty + document.qtymai n.qty.item(i).v alue


document.qtymai n.qty.item[i].value

I suspect.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #3
"Evertjan." <ex************ **@interxnl.net > writes:
amy wrote on 16 okt 2003 in comp.lang.javas cript:
ttlqty = ttlqty + document.qtymai n.qty.item(i).v alue


document.qtymai n.qty.item[i].value

I suspect.


Probably not. It sounds like document.qtymai n.qty is a collection.
These have a method called "item" (and some also have "namedItem" ).

The equivalent notation would be
document.qtymai n.qty[i].value

I assume qtymain is a form and qty is the name of some elements in
the form. The elements are probably checkboxes, since they have
been given the same name.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Lasse Reichstein Nielsen wrote on 16 okt 2003 in comp.lang.javas cript:
"Evertjan." <ex************ **@interxnl.net > writes:
amy wrote on 16 okt 2003 in comp.lang.javas cript:
> ttlqty = ttlqty + document.qtymai n.qty.item(i).v alue

document.qtymai n.qty.item[i].value
I suspect.


Probably not. It sounds like document.qtymai n.qty is a collection.
These have a method called "item" (and some also have "namedItem" ).

The equivalent notation would be
document.qtymai n.qty[i].value

I assume qtymain is a form and qty is the name of some elements in
the form. The elements are probably checkboxes, since they have
been given the same name.


Would the qty[i] form be more tolerant of a stringed number, Lasse ?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5


yes, the qtymain is a form, qty is a collection of input box. I try to
get all the value throught the loop, and get the total. The value I get
is correct, just add up became concatenate.
document.qtymai n.qty.item[i].value
doesn't help. still doing concatename.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #6
"Evertjan." <ex************ **@interxnl.net > writes:
Would the qty[i] form be more tolerant of a stringed number, Lasse ?


Probably not. I would expect square bracket notation and the "item"
function to behave the same.

The HTMLCollection interface is defined in the W3C DOM 2 HTML
specification:
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
In the ECMAScript bindings it says that using
collection[1]
is equivalent to
collection.item (1)

However, in ECMAScript, collection[1] is equivalent to
collection["1"], since all property names are converted to strings
before being looked up.

Likewise, the "item" function might convert its argument to a number
before using it. It doesn't have to, though. I can see that
document.links. item("0x0")
isn't the same as
document.links. item("0")
in Opera.
/Lc
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #7
amy J wrote on 16 okt 2003 in comp.lang.javas cript:
yes, the qtymain is a form, qty is a collection of input box. I try to
get all the value throught the loop, and get the total. The value I get
is correct, just add up became concatenate.
document.qtymai n.qty.item[i].value
doesn't help. still doing concatename.

<script>

// You can prevent a concatenation by

alert(1*"11"+1* "7") //this will give 18

// or

alert(+"11"+ +"7") //this will also give 18

//while

alert("11"+"7") //this will give 117
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #8


Evertjan, thanks for the correct answer.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #9

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

Similar topics

2
3435
by: Frank | last post by:
When I used IE 6.0 to view the ASP page on Window 2000 server PC, I encountered the error message: "Expected end of statement". The ASP page code is as: ****************************************************** <script language="VBScript"> function vb_Test(ptValue) vb_Test = ptValue end function
3
13285
by: Rahul Bakshi | last post by:
Hi I am getting this error which is frustrating me a lot Microsoft VBScript runtime error '800a01c9' This key is already associated with an element of this collection /process.asp, line 362
12
6478
by: MFA | last post by:
Hi All Thanks to all who replied to my question dated 16/10/2003 with the same subject.. In all replies I got every one is saying that I am using cint() etc. But i am not using any convert method. What I am using.
29
6006
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
20
5960
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client javascript code and work out what it does but I can't really write it from scratch.
3
6041
by: pjglick | last post by:
I am sorry if this sounds hokey but I am a newbie to ASP. I have a VBScript running in an ASP page. The script makes a connection to Oracle via and ADODB connection. When my clients connect to the ASP page they get Oracle client issues. How do I make the script run from the server side to eliminatew any oracle client issues or oracle tns names issues.
2
2877
by: Beemer Biker | last post by:
I put together a few lines of vbscript so I could dump the contents of a string to my C drive. It worked fine in a small test.htm where I put the vbscript at the top of the file. It failed to work (no error message) in my large program where I needed to dump out the stuff. I did get an error message from FrontPage 2003 but it was not informative. When moved the vbscript to the bottom of the page it worked fine! ========start of...
10
8015
by: jasone | last post by:
hi everyone! any advice given will be MUCH appreciated, i have spent about 10 hours on this bit of script... a rating system. I am having realt trouble overcoming this problem at runtime Microsoft VBScript runtime (0x800A01A8) Object required: '' /ddwassignment2/full_catalogue2.asp, line 180 please find the complete code listing below, i have highlighted line 180... if you spot any other errors please let me know! The function...
2
2783
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. Herein lies the problem; if the order number is 0, I do not want the grid to display anything. If...
0
7896
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8389
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5848
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3896
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1503
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.