1
thenoob
7y

Can anyone here help me with a super simple JavaScript code which I want to include externally with html?

Comments
  • 1
    sure, what's the issue?
  • 0
    So this is my html
  • 0
    And this is my .js file .... Why isn't it working ? What's the issue ?
  • 0
    Because as I already checked on several sites I did everything right 😅 can't find my mistake
  • 1
    Currently:
    Expected:
  • 0
    Currently it shows nothing on the second row ... It should show 251, XX €
    It worked when I had it directly entered in my html file with script tags but since I tried to have it externally it doesn't work anymore
  • 1
    you just declared your netto function, but never call it.
  • 0
    Just called it but it still doesn't work
  • 1
    @thenoob can you put your code somewhere. Reading code on photos isn't really useful.
  • 0
    Where would you prefer it ? I'm new to this so I haven't got any clue how or where to share code 😅
  • 1
    @thenoob code goes always best to github
  • 0
    Alright. I will upload it on github the first thing in the morning . I managed to get it work with buttons but not automatically ... Very strange somehow. Thank you for your help, will post the github link in few hours
  • 0
    Not really sure since I'm viewing the screenshots on mobile. It seems you are defining the function but you are not calling it anywhere. Either add an event listener on page load that calls the netto function (your best choice) or simply call it immediately by adding a pair of parenthesis after the definition like: (function netto(){/*code*/})()
Add Comment