multiple two numbers then result sum with another number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • merkam
    New Member
    • Dec 2009
    • 2

    multiple two numbers then result sum with another number

    hi,
    i need a script that:
    step1: multiple n*1200= m
    n=0 or 1 or 2 ...
    step2: sum m+10+20
    i have this script
    i don't now how to assign span with id="five" to value in checkbox plz help me
    Code:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="sum.aspx.vb" Inherits="sum" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>sum</title>
    </head>
    <body>
        <form id="form1" runat="server">
        				
    		<table width="auto" border="0" cellspacing="10" cellpadding="2" align="center">			
    			<tr>
    				<td colspan="2" align="center"> </td>
    			</tr>
    			
    		</table>
    		<table >
    		  <tr align="center">
                                    <td class="ContentCell">
                                        1</td>
                                    <td class="ContentCell">
                                        Loop</td>
                                    <td class="ContentCell">
                                        171</td>
                                    <td class="ContentCell" align="center">
                                        <input onclick="clickCh(this)" type="checkbox" runat="server" id="txtAdaRate" name="one"
                                            value="171" />
                                    </td>
                                </tr>
                                <tr align="center">
                                    <td class="ContentCell">
                                        2</td>
                                    <td class="ContentCell">
                                        Loop rate</td>
                                    <td class="ContentCell">
                                        115</td>
                                    <td class="ContentCell" align="center">
                                        <input onclick="clickCh(this)" type="checkbox" runat="server" id="txtFixRate" name="two"
                                            value="115" />
                                    </td>
                                </tr>
                                <tr align="center">
                                    <td class="ContentCell">
                                        3</td>
                                    <td class="ContentCell">
                                        Loop bridge </td>
                                    <td class="ContentCell">
                                        1153</td>
                                    <td class="ContentCell" align="center">
                                        <input onclick="clickCh(this)" type="checkbox" runat="server" id="txtBridTap" name="three"
                                            value="1153" />
                                    </td>
                                </tr>
                                <tr align="center">
                                    <td class="ContentCell">
                                        4</td>
                                    <td class="ContentCell">
                                       test</td>
                                    <td class="ContentCell">
                                        45</td>
                                    <td class="ContentCell" align="center">
                                        <input onclick="clickCh(this)" type="checkbox" runat="server" id="txtThroTest" name="four"
                                            value="45" />
                                    </td>
                                </tr>
                                <tr align="center">
                                    <td class="ContentCell">
                                        5</td>
                                    <td class="ContentCell">
                                        Latency test</td>
                                    <td class="ContentCell">
                                        122200</td>
                                    <td class="ContentCell" align="center">
                                    <input type="text" name="mah" id="Text1" size="4" value="1" border="0" style="font-size:16px;font-weight:bold;align:center" onchange="upPrice(this.value);" onkeyup="upPrice(this.value);">
                                    <span id="five" style="font-size:12px;">25,000</span>
                                        <input onclick="clickCh(this)" type="checkbox" runat="server" 
                                            name="five" value="session("span.five")" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="ContentCell" colspan="2" align="center">
                                        
                                    </td>
                                    <td class="ContentCell" colspan="2">
                                        <input id="total" type="text" name="total" runat="server" readonly="readonly" style="font-family: Tahoma;
                                            font-size: 12px;" />
                                    </td>
                                </tr>
    		</table>
    		<script language="JavaScript" type="text/javascript">
    var total = document.getElementById("total")
    function clickCh(caller){
    if(caller.checked){
    add(caller)
    } else {
    subtract(caller)
    }
    }
    function add(caller){ total.value = total.value*1 + caller.value*1}
    function subtract(caller){ total.value = total.value*1 - caller.value*1}
        </script>
    			<script language ="javascript" >
    		
    		function upPrice(m){
    			m=parseInt(m);
    			if(m>=0){
    				span=document.getElementById('five');
    				perM=13398948;
    				span.innerHTML=formatNUM((perM*m));
    			}else{
    				span.innerHTML='';
    			}
    		}
    		function formatNUM(number) {
    		        var nStr = '' + Math.round(parseFloat(number) * 100) / 100;
    		        var x = nStr.split('.');
    		        var x1 = x[0];
    		        var x2 = x.length > 1 ? '.' + x[1] : '';
    		        var rgx = /(\d+)(\d{3})/;
    		        while (rgx.test(x1)) {
    		            x1 = x1.replace(rgx, '$1' + ',' + '$2');
    		        }
    		        return x1 + x2;
    		    };
    		
    		</script>
        </form>
    </body>
    </html>
    Last edited by tlhintoq; Dec 30 '09, 03:36 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    posting such long code snippets will not help...

    summarise your point please

    Comment

    • merkam
      New Member
      • Dec 2009
      • 2

      #3
      hi,
      i need a script that:
      step1: multiple n*1200= m
      n=0 or 1 or 2 ... user input n
      step2: sum m+10+20
      such as
      10
      20
      n*1200
      sum = 10+20+n*1200
      user can select 10 or 20 and input n

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        i doubt its not a home work question.....
        and i think bytes has a policy that we don't help school kids with their home work..

        that's bcoz you have asked a very simple question... sorry

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

          Comment

          • tlhintoq
            Recognized Expert Specialist
            • Mar 2008
            • 3532

            #6
            Bytes has a policy regarding assisting students with their homework.

            The short version is that the volunteers here can't help you with schoolwork.
            A) We don't know what material you have and have not learned in class.
            B) We don't know the guidelines you must follow.
            C) In the long run giving you the answers actually short changes your education.

            Comment

            Working...