JavaScript - how to multiply given numbers

Asked By fitz
30-Aug-10 09:50 PM
hello, can u help me in my assign.. i have problem solving this kind of program.. if you can help me, kindly reply.
kindly run it on html... the total must be qty*7.50... and so on for other ITEMS.. THx
<html>
<head>
      <title>ShopWee</title>
      <script language="javascript">    

      </script>
  </head>

<body>
    Qty&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    Item&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    Unitprice&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    Total<br>
    <input type="text" size = "2" id="value1" name="value1" value=""/>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; ballpen
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; 7.50
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; <input type="text" size="2"/><br><br>

    
    <input type="text" size = "2" id="value1" name="value1" value=""/>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; pencil
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; 4.75
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; <input type="text" size="2"/><br><br>

    <input type="text" size = "2" id="value1" name="value1" value=""/>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; yellow paper
    &nbsp;0.90
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; <input type="text" size="2"/><br><br>

    <input type="text" size = "2" id="value1" name="value1" value=""/>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; notebook
    &nbsp&nbsp&nbsp&nbsp&nbsp; 25.25
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; <input type="text" size="2"/><br><br>

    <input type="button" name="Sumbit" value="Compute">
     &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; Grand Total
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;<input type="text" size="2"/><br><br>

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; Amount Tendered
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;<input type="text" size="2"/><br><br>


    
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp; Change
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;<input type="text" size="2"/>




</body>
</html>
  sri sri replied to fitz
30-Aug-10 11:14 PM
hi,

try the below code

Product 1 <input type="text" id="qty1" name="qty1" ><input type="text" id="Price1" name="Price1" value="7.50">
<input type="text" id="tot1" name="tot1">

Product 2 <input type="text" id="qty2" name="qty2" ><input type="text" id="Price2" name="Price2" value="10.50">
<input type="text" id="tot2" name="tot1">

<input type="button" onclick="calculate();" value="ok">

<script language="javascript">
function calculate()
{
    document.getElementById("tot1").value = document.getElementById("qty1").value * document.getElementById("Price1").value;
    document.getElementById("tot2").value = document.getElementById("qty2").value * document.getElementById("Price2").value;
}
  Mash B replied to fitz
31-Aug-10 01:47 AM
You can do this like this.
 
function MultiplyTwoNumber()
{
var a=document.getElementById(<controlId>).value;
var b=document.getElementById(<controlId>).value;
 
var c = parseFloat(a) * parseFloat(b) ;
 
document.getElementById(<labelcontrolid>).value = c;
 
}
 
Call this from button control.
<asp:Button OnClientClick="return MultiplyTwoNumber();" Text="Multiply" runat="server" />
Create New Account
help
height = 1 src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<a href = "javascript: parent.writeprops0()" / a> Summary') w1('< / SPAN> ') w1('< / TD> ') w1('< / TR> ') w1('<TR> ') w1('<TD valign src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<BLOCKQUOTE> ') w1('<a href = "javascript: parent.writeprops1()" / a> Operating Date : OD+1') w1('< / BLOCKQUOTE> ') w1('< / SPAN> ') w1('< / TD> ') w1('< / TR src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<BLOCKQUOTE> ') w1('<a href = "javascript: parent.writeprops2()" / a> Pre-Conditions : Load forecast for OD+1 exists.') w1('< / BLOCKQUOTE> ') w1('< / SPAN src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<BLOCKQUOTE> ') w1('<a href = "javascript: parent.writeprops3()" / a> Post-Conditions : Non- Participating Loads bids submitted to CAISO') w1('< / BLOCKQUOTE> ') w1 height = 1 src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<a href = "javascript: parent.writeprops4()" / a> Initialize Bid Package ') w1('< / SPAN> ') w1('< / TD> ') w1('< / TR> ') w1('<TR> ') w1 src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<BLOCKQUOTE> ') w1('<a href = "javascript: parent.writeprops5()" / a> Bid Formulator -> Bid Packages') w1('< / BLOCKQUOTE> ') w1('< / SPAN> ') w1('< / TD> ') w1('< / TR src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<BLOCKQUOTE> ') w1('<a href = "javascript: parent.writeprops6()" / a> Select today’s Operating Date (OD)') w1('< / BLOCKQUOTE> ') w1('< / SPAN> ') w1('< / TD src = "pixelshim.gif" width = 16> < / TD> ') w1('<TD> ') w1('<SPAN> ') w1('<BLOCKQUOTE> ') w1('<a href = "javascript: parent.writeprops7()" / a> Place the cursor on the Package Name you wish to use to
a screen-shot: ( Error page high lighted in red ) Hi Zainab, You are getting a Javascript Error. Click on that yellow icon to get the details of error and share it href = " / orgs / 30002061 / 30008332 / 30018027 / _themes / classic / clas1011-65001.css?rev = 12%2E0%2E0%2E6514" / > <script type = "text / javascript" language = "javascript" src = " / _layouts / 1033 / init.js?rev = w7H9f6YxfzEXRgXKUMfiTg%3D%3D"> < / script> <script type = "text / javascript" language = "javascript" src = " / _layouts / portal.js?rev = cRI8b5r5N%2BkLhIuWR03ICg%3D%3D"> < / script> <script type = "text / javascript" language = "javascript" src = " / _layouts / 1033 / ie55up.js?rev = Ni7%2Fj2ZV%2FzCvd09XYSSWvA%3D%3D"> < / script> <script type = "text javascript" language = "javascript" src = " / _layouts / 1033 / EditingMenu.js?rev = rJmArN6GZh8xCWZG4gneDQ%3D%3D"> < / script> <link type = "text / xml" rel
How to sum and display total in a label using javascript ASP.NET I am having a grid view as follows I have written a javascript to display Amount now I would like to display the total of Amount from the in the label avaiable. This is my script to display Amount 1. <script type = "text / javascript" > 2. function multiplication(txtQuantity, txtRate, txtAmount) { 3. var totalDTH = 0; 4. var weight = document.getElementById Namespace = "AjaxControlToolkit" TagPrefix = "asp" %> < asp:Content ID = "Content1" ContentPlaceHolderID = "ContentPlaceHolder1" runat = "Server" > <%- -< script type = "text / javascript" > function disableEnterKey(e) { var key; if(window.event) key = window.event.keyCode; / / IE else key = e.which; / / firefox return (key ! = 13); } < / script > - -%> < script type = "text / javascript" src = "http: / / ajax.googleapis.com / ajax / libs / jquery / 1.4 / jquery.min.js" > < / script > < script src = "tooltipinv / js.js" type = "text / javascript" > < / script > < script type = "text / javascript" > function stopRKey(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt evt.keyCode = = 13) && (node.type = = "text")) { return false; } } document.onkeypress = stopRKey; < / script > < script type = "text / javascript" > var GridId = "<% = grdInvoice.ClientID %> "; var ScrollHeight = 300; window.onload = function () { var grid = document.getElementById(GridId
what is the diffrence between javascript &Ajax. . ? what is the diffrence between javascript &Ajax. . ? hi, AJAX : Ajax is the acronym for Asynchronous JavaScript and XML. It incorporates a suite of technologies aimed at improving user experience with web on an as-need basis without requiring the re-loading of the entire web page. JavaScript: Javascript, on the other hand, is a client side scripting language that allows the creation of dynamic web pages providing a new level of interactivity. The advantage of JavaScript is that since it's a client side application, it can create dynamic web pages when there are a lot of people accessing that server. Being on the client computer, Javascript has a lot of resources to play regardless of the activity on the server. The prime drawback of Javascript is that it is a very good candidate for a trojan to be installed into
please explain HI, WHAT IS THE DIFFERENCE BETWEEN VBSCRIPT AND JAVASCRIPT hi, Java Script and VB Script are both programming languages that programmers use as tools to develop applications for personal computers. JavaScript is a client-side scripting language; it is interpreted (and statements executed) by a user server (specifically, IIS). VBScript and IIS (Internet Information Server) are Microsoft products. According to Wikipedia: "JavaScript is an object-oriented scripting language used to enable programmatic access to objects within both the client application and other applications. . . . JavaScript was influenced by many languages and was designed to look like Java, but to be as a limited variation of Microsoft's Visual Basicprogramming language." Hope this will help you Javascript = = = = = = = = = = = = = = Javascript case sensitive. Javascript will be run on client side. javascript support all the browser VBScript = = = = = = = = = = = = = = VBScript not case sensitive. VBScript will be run on server