Bitcoin Forum
November 10, 2024, 01:45:37 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Easy code help needed (0.10 BTC Bounty)  (Read 1641 times)
TheBitMan (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250



View Profile
June 13, 2012, 07:38:29 PM
 #1

Code:
<html>  
      
    <head>  

    <script language="javascript" type="text/javascript">  
    function multiply(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a*b;  
    document.calculator.total.value=c;  
    }  
    </script>  
  
    </script>  
      
    </head>  
      
    <body>  
      
    <!-- Opening a HTML Form. -->  
    <form name="BTC Cost">  
      
    <!-- Here user will enter 1st number. -->  
    BTC Price: <input type="text" name="number1">  
      
      
    <!-- Here user will enter 2nd number. -->  
    Amount Of BTC You Want: <input type="text" name="number2">  
      
      
    <!-- Here result will be displayed. -->  
    Get Result: <input type="text" name="total">  
      
      
    <!-- Here respective button when clicked, calls only respective artimetic function. -->    
    <input type="button" value="Multiply" onclick="javascript:multiply();">  
  
      
    </form>  
      
    </body>  
    </html>  

I need the first number to have a default value of 8.50
And anyway to change the color of things would help to.
Maged
Legendary
*
Offline Offline

Activity: 1204
Merit: 1015


View Profile
June 13, 2012, 08:25:37 PM
 #2

Code:
<html>  
      
    <head>  

    <script language="javascript" type="text/javascript">  
    function multiply(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a*b;  
    document.calculator.total.value=c;  
    }  
    </script>  
  
    </script>  
      
    </head>  
      
    <body>  
      
    <!-- Opening a HTML Form. -->  
    <form name="BTC Cost">  
      
    <!-- Here user will enter 1st number. -->  
    BTC Price: <input type="text" name="number1" value="8.50">  
      
      
    <!-- Here user will enter 2nd number. -->  
    Amount Of BTC You Want: <input type="text" name="number2">  
      
      
    <!-- Here result will be displayed. -->  
    Get Result: <input type="text" name="total">  
      
      
    <!-- Here respective button when clicked, calls only respective artimetic function. -->    
    <input type="button" value="Multiply" onclick="javascript:multiply();">  
  
      
    </form>  
      
    </body>  
    </html>  
What do you want the color of changed?

TheBitMan (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250



View Profile
June 13, 2012, 08:29:11 PM
 #3

Code:
<html>  
      
    <head>  

    <script language="javascript" type="text/javascript">  
    function multiply(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a*b;  
    document.calculator.total.value=c;  
    }  
    </script>  
  
    </script>  
      
    </head>  
      
    <body>  
      
    <!-- Opening a HTML Form. -->  
    <form name="BTC Cost">  
      
    <!-- Here user will enter 1st number. -->  
    BTC Price: <input type="text" name="number1" value="8.50">  
      
      
    <!-- Here user will enter 2nd number. -->  
    Amount Of BTC You Want: <input type="text" name="number2">  
      
      
    <!-- Here result will be displayed. -->  
    Get Result: <input type="text" name="total">  
      
      
    <!-- Here respective button when clicked, calls only respective artimetic function. -->    
    <input type="button" value="Multiply" onclick="javascript:multiply();">  
  
      
    </form>  
      
    </body>  
    </html>  
What do you want the color of changed?
never mind it came out good. But it wont multiply now..
Maged
Legendary
*
Offline Offline

Activity: 1204
Merit: 1015


View Profile
June 13, 2012, 08:37:04 PM
 #4

Since I'm not used to the old way of getting a node from a form, I just went with the way that I normally do it:
Code:
<html>  
     
    <head> 

    <script language="javascript" type="text/javascript"> 
    function multiply(){ 
    a=Number(document.getElementById("number1").value); 
    b=Number(document.getElementById("number2").value); 
    c=a*b; 
    document.getElementById("total").value=c; 
    } 
    </script> 
 
    </script> 
     
    </head> 
     
    <body> 
     
    <!-- Opening a HTML Form. -->   
    <form name="BTC Cost"> 
     
    <!-- Here user will enter 1st number. -->   
    BTC Price: <input type="text" name="number1" id="number1" value="8.50">   
       
     
    <!-- Here user will enter 2nd number. -->   
    Amount Of BTC You Want: <input type="text" name="number2" id="number2">   
     
     
    <!-- Here result will be displayed. -->   
    Get Result: <input type="text" name="total" id="total">   
     
     
    <!-- Here respective button when clicked, calls only respective artimetic function. -->   
    <input type="button" value="Multiply" onclick="javascript:multiply();"> 
 
     
    </form> 

TheBitMan (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250



View Profile
June 13, 2012, 08:40:52 PM
 #5

Since I'm not used to the old way of getting a node from a form, I just went with the way that I normally do it:
Code:
<html>  
     
    <head> 

    <script language="javascript" type="text/javascript"> 
    function multiply(){ 
    a=Number(document.getElementById("number1").value); 
    b=Number(document.getElementById("number2").value); 
    c=a*b; 
    document.getElementById("total").value=c; 
    } 
    </script> 
 
    </script> 
     
    </head> 
     
    <body> 
     
    <!-- Opening a HTML Form. -->   
    <form name="BTC Cost"> 
     
    <!-- Here user will enter 1st number. -->   
    BTC Price: <input type="text" name="number1" id="number1" value="8.50">   
       
     
    <!-- Here user will enter 2nd number. -->   
    Amount Of BTC You Want: <input type="text" name="number2" id="number2">   
     
     
    <!-- Here result will be displayed. -->   
    Get Result: <input type="text" name="total" id="total">   
     
     
    <!-- Here respective button when clicked, calls only respective artimetic function. -->   
    <input type="button" value="Multiply" onclick="javascript:multiply();"> 
 
     
    </form> 
thanks btc sent to your sig address!
Maged
Legendary
*
Offline Offline

Activity: 1204
Merit: 1015


View Profile
June 13, 2012, 08:41:14 PM
 #6

Thanks  Smiley

Maged
Legendary
*
Offline Offline

Activity: 1204
Merit: 1015


View Profile
June 13, 2012, 08:46:36 PM
 #7

If you want to learn more JavaScript and HTML, W3Schools is a good place to learn. A lot of this was pretty much JavaScript and HTML 101.

TheBitMan (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250



View Profile
June 13, 2012, 08:49:06 PM
 #8

If you want to learn more JavaScript and HTML, W3Schools is a good place to learn. A lot of this was pretty much JavaScript and HTML 101.
thanks
unfinishe
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
June 13, 2012, 09:45:06 PM
 #9

Wait, why do you have two </script> tags?

Check out the results from my Bitcoin Survey Project!
https://bitcointalk.org/index.php?topic=88927.0
TheBitMan (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250



View Profile
June 13, 2012, 10:26:29 PM
 #10

Wait, why do you have two </script> tags?
I dont know..lol
Maged
Legendary
*
Offline Offline

Activity: 1204
Merit: 1015


View Profile
June 13, 2012, 10:32:50 PM
 #11

Wait, why do you have two </script> tags?
Lol, totally didn't even notice that. The browser parses it just fine  Undecided

unfinishe
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
June 14, 2012, 12:47:16 PM
 #12

Yeah, browsers are sure easy-going, but I still can't help being a stickler for correctness. (Not to say that I don't make mistakes myself, though) Wink

Check out the results from my Bitcoin Survey Project!
https://bitcointalk.org/index.php?topic=88927.0
Maged
Legendary
*
Offline Offline

Activity: 1204
Merit: 1015


View Profile
June 14, 2012, 07:56:44 PM
 #13

Yeah, browsers are sure easy-going, but I still can't help being a stickler for correctness. (Not to say that I don't make mistakes myself, though) Wink
I know. I sort of hate that browsers are so forgiving, since it makes it hard to catch stuff like this.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!