Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: TheBitMan on June 13, 2012, 07:38:29 PM



Title: Easy code help needed (0.10 BTC Bounty)
Post by: TheBitMan on June 13, 2012, 07:38:29 PM
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.


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: Maged on June 13, 2012, 08:25:37 PM
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?


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: TheBitMan on June 13, 2012, 08:29:11 PM
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..


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: Maged on June 13, 2012, 08:37:04 PM
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> 


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: TheBitMan on June 13, 2012, 08:40:52 PM
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!


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: Maged on June 13, 2012, 08:41:14 PM
Thanks  :)


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: Maged on June 13, 2012, 08:46:36 PM
If you want to learn more JavaScript and HTML, W3Schools (http://www.w3schools.com/) is a good place to learn. A lot of this was pretty much JavaScript and HTML 101.


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: TheBitMan on June 13, 2012, 08:49:06 PM
If you want to learn more JavaScript and HTML, W3Schools (http://www.w3schools.com/) is a good place to learn. A lot of this was pretty much JavaScript and HTML 101.
thanks


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: unfinishe on June 13, 2012, 09:45:06 PM
Wait, why do you have two </script> tags?


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: TheBitMan on June 13, 2012, 10:26:29 PM
Wait, why do you have two </script> tags?
I dont know..lol


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: Maged on June 13, 2012, 10:32:50 PM
Wait, why do you have two </script> tags?
Lol, totally didn't even notice that. The browser parses it just fine  :-\


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: unfinishe on June 14, 2012, 12:47:16 PM
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) ;)


Title: Re: Easy code help needed (0.10 BTC Bounty)
Post by: Maged on June 14, 2012, 07:56:44 PM
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) ;)
I know. I sort of hate that browsers are so forgiving, since it makes it hard to catch stuff like this.