Multiply an entry - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Multiply an entry

webuserwebuser Posts: 3Member
I want to add a script to multiply an user input and
show the result beside the input text box. Is there
any one to help?

Comments

  • mac_doggiemac_doggie Posts: 488Member
    I don't know if you still need it, but I think you need something like this...?


    [code]



    function Multiply() {
    document.getElementById('result').innerText = document.getElementById('userinput').value * 3;
    }






    [/code]

    : I want to add a script to multiply an user input and
    : show the result beside the input text box. Is there
    : any one to help?
    :

    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


  • webuserwebuser Posts: 3Member
    Dear mac, I used this:




    function TotalCost()
    {
    if (document.MainForm.BookNumber.value<1)
    {document.MainForm.Cost.value="NaN";}
    else {document.MainForm.Cost.value=document.MainForm.BookNumber.value*600+100}
    }
    </script>






    What's your idea?
  • mac_doggiemac_doggie Posts: 488Member
    I think that will work also, but I prefer using the document.getElementById() function to avoid problems with different browsers...

    -mac-

    : Dear mac, I used this:
    :
    :
    :
    :
    : function TotalCost()
    : {
    : if (document.MainForm.BookNumber.value<1)
    : {document.MainForm.Cost.value="NaN";}
    : else {document.MainForm.Cost.value=document.MainForm.BookNumber.value*600+100}
    : }
    : </script>
    :
    :
    :
    :
    :
    :
    : What's your idea?
    :

    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


Sign In or Register to comment.