Skip to content
Advertisement

Can’t get the JS script to output data on HTML page

My code below is a simple form which takes an integer, and a yes/no radio button pair. If ‘yes’ is selected (the left option) then the value you entered * 0.13 should be displayed – if ‘no’ is selected (or neither are selected) then the value 0 should be displayed. It is not working as expected – how can I fix this problem?

JavaScript

Advertisement

Answer

The issues I found are as follows:

  1. The script hasn’t been evaluated yet so solve is not defined. I’ve used an ID on that button and added an event listener instead.
  2. You should be accessing Form1.Nalog not Form1.nalog (note the capitalisation of the name attribute matters).

Here’s a working demo with those changes applied:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement