It seems working :
HTML :
<input type='text' id="pointspossible"/> <input type='text' id="pointsgiven" /> <input type='text' id="pointsperc" disabled/>
JavaScript :
$(function(){ $('#pointspossible').on('input', function() { calculate(); }); $('#pointsgiven').on('input', function() { calculate(); }); function calculate(){ var pPos = parseInt($('#pointspossible').val()); var pEarned = parseInt($('#pointsgiven').val()); var perc=""; if(isNaN(pPos) || isNaN(pEarned)){ perc=" "; }else{ perc = ((pEarned/pPos) * 100).toFixed(3); } $('#pointsperc').val(perc); } });
Demo : http://jsfiddle.net/vikashvverma/1khs8sj7/1/
Related Posts:
- Edit webpage with javascript trick – how to “unedit”?
- Automatically pausing html5 video as the ‘next’ button is pressed (javascript/ jquery)
- Is it possible to write data to file using only JavaScript?
- Remove CSS class from element with JavaScript (no jQuery) [duplicate]
- Is it possible to write data to file using only JavaScript?
- How to make JavaScript execute after page load?
- Set cookie and get cookie with JavaScript
- Which is better: or
- Onclick javascript to make browser go back to previous page?
- How to make JavaScript execute after page load?
- Why is my Javascript not working?
- How can I get the values of data attributes in JavaScript code?
- Javascript: getElementById vs getElementsById (both works on different pages)
- mailto using javascript
- mailto using javascript
- Mailto using Javascript?
- How to change css property using javascript
- javascript close current window
- I am trying to make a simple toggle button in javascript
- How to call a JavaScript function within an HTML body
- How to save user input into a variable in HTML and JavaScript
- Hiding a button in Javascript
- Show/hide ‘div’ using JavaScript
- How to make JavaScript execute after page load?
- Get HTML code using JavaScript with a URL
- How to display image with JavaScript?
- Resize image with javascript canvas (smoothly)
- JavaScript function onhover in
- Check if an element contains a class in JavaScript?
- Hide element by class in pure Javascript
- How to play a mp3 using Javascript? [duplicate]
- mailto using javascript
- Function not defined javascript
- How to submit a form with JavaScript by clicking a link?
- How to call a REST web service API from JavaScript?
- Check a radio button with javascript
- AppendChild() is not a function javascript
- How can I change an element’s class with JavaScript?
- JavaScript: Get image dimensions
- Why write script type=”text/javascript” when the mime type is set by the server?
- How to select an input element by value using javascript?
- javascript window.location in new tab
- How to create a hidden in JavaScript?
- How do I programmatically set the value of a select box element using JavaScript?
- How can I capture the right-click event in JavaScript?
- How do I clear the content of a div using JavaScript?
- Failed to load resource: the server responded with a status of 404 (Not Found)
- How to make a word underline in Markdown
- What does enctype=’multipart/form-data’ mean?
- Link with target=”_blank” and rel=”noopener noreferrer” still vulnerable?
- What does do?
- Angular: mat-form-field must contain a MatFormFieldControl
- Use images like checkboxes
- What is href=”#” and why is it used?
- How do I scroll to an element using JavaScript?
- Get the value in an input text box
- HTML img scaling
- An invalid form control with name=” is not focusable
- How to call a PHP function on the click of a button
- Adding background image to div using CSS
- Center a DIV horizontally and vertically
- how to overwrite css style
- How can I move this text up using CSS?
- Multiple Forms or Multiple Submits in a Page?
- Target a css class inside another css class
- Mailto on submit button
- CSS float right not working correctly
- How can I vertically align elements in a div?
- How to give spacing between buttons using bootstrap
- why angularjs ng-repeat not working
- HTML input – name vs. id
- How to add image that is on my computer to a site in css or html?
- External CSS not working
- How to exclude particular class name in CSS selector?
- How to scroll to top of a div using jQuery?
- getContext is not a function
- HTML/CSS–Creating a banner/header
- Change hover color on a button with Bootstrap customization
- Alternate table row color using CSS?
- Strip HTML from Text JavaScript
- CSS “and” selector – Can I select elements that have multiple classes?
- Calling a JavaScript function in another js file
- JavaScript code not running in HTML5 document
- Unexpected token < in first line of HTML
- How to set “style=display:none;” using jQuery’s attr method?
- How do I make my wordpress page more friendly for mobile viewers?
- #text at the begging of every page, before the main content block
- How to keep HTML form field that is conditional hidden with javasript hidden after page reload?
- How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?
- The correct way to add a JavaScript in the functions.php [closed]
- Convert bookmarks.html file into WP posts
- Excerpt keep stripping tags
- What file is the tag located in Genesis default theme?
- Show preview of wordpress posts on external html sever
- Applying metatag to single page
- scroll scrpit to particular button position to next id when click button
- Trouble with adding preloader to my home page index.html and index.js
- Link opens a new website instead of my own
- How to play a video after the end of another one via link?
- Moving from Microsoft Front Page 2003 to WordPress