Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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:mac_doggie@hotmail.com
    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:mac_doggie@hotmail.com
    the Netherlands...


Sign In or Register to comment.