Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Javascript Help???

  • 02-09-2010 4:56pm
    #1
    Registered Users, Registered Users 2 Posts: 263 ✭✭


    Hi guys, I have 2 input labels in a form and i wanna be able to do some calculation and output to another label, without the user having to do more than input details into the 2 input boxs... No buttons to click if you know what i mean... I know how to do this in vb, but am unsure if ya can do it in javascript... Can someone help please?

    Any information much appreciated


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    Attach some events to the text inputs, onkeyup and/or onchange should do it... or there's more here that might suit depending on what form inputs you're using.
    Basically have those events call your function which reads the field's values every time.
    Then use .innerHTML or whatever to output the result.

    Rough example...
    <head>
    function doSomething()
    {
      var something1 = document.getElementById('field1').value;
      var something2 = document.getElementById('field2').value;
    
      // do whatever
    
      document.getElementById('result').innerHTML = "The answer is " + answer;
    }
    
    <body>
    <input type="text" id="field1" onkeyup="doSomething()">
    <input type="text" id="field2" onkeyup="doSomething()">
    <span id="result"></span>
    


Advertisement