/    Sign up×
Community /Pin to ProfileBookmark

Why My Java Calculator Not Work?

here is html…


<!DOCTYPE html>
<title>My WebsiteB</title>
<link rel=”stylesheet” type=”text/css” href=”stylesB.css” />
<meta charset=”utf-8″>
<meta name=”description”
content=”” />
<meta name=”keywords”
content=”” />
<meta http-equiv=”author”
content=”” />
<meta http-equiv=”pragma”
content=”no-cache” />
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<h1>Clock Numerology Calculator</h1>
<div class=”nav”>
<h3>Converts Words Into Numbers</h3>
<p>Enter Word(s) Or Phrase:</p>
<div class=”content”>
<input type=”text”>
<button onclick=”calculate()”>Calculate</button>
<div class=”result”></div>
[script src=”JavascriptB.js”>[/script>
<ul id=”list-one”>
<label id=”label-one”>Number Description Database</label>
<li><a href=”Tens.html”>0-99</a></li>
<table id=”encryption” border=”black”>
<tr align=”center”>
<th bgcolor=”lightgrey”>2</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>3</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>12</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>11</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>15</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>17</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>18</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>13</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>10</th>
<tr align=”center”>
<th bgcolor=”lightgrey”>7</th>


Finally, here is Java…

‘a’: 2, ‘b’: 3, ‘c’: 12, ‘d’: 11, ‘e’: 15, ‘f’: 17, ‘g’: 18, ‘h’: 13, ‘i’: 10, ‘j’: 7, ‘k’: 7, ‘l’: 10, ‘m’: 13, ‘n’: 13, ‘o’: 10, ‘p’: 7, ‘q’: 7, ‘r’: 10, ‘s’: 13, ‘t’: 18, ‘u’: 17, ‘v’: 15, ‘w’: 11, ‘x’: 12, ‘y’: 3, ‘z’: 2


var input = document.querySelector(‘input’);
var button = document.querySelector(‘button’);
var result = document.querySelector(‘.result’);

function calculate(){
result.innerHTML = ”;

printResult(NUMEROLOGY, ‘Numerology’);

function printResult(list, text) {
var letters = input.value.toLowerCase().replace(/[^0-9a-z])/g, ”).split(”);
var sum = 0, l, i;
for(i = 0; i < letters.length; i++){
l = letters[i];
sum += list[l] || parseInt(l);

result.innerHTML += ‘<div class=”result-text”>’ + text + ‘ ‘ + ‘</div>’;


FYI, I got the calculator code from a Coding Website. When I run it on that site, it works. But when I run it in my browser as my own webspage, it doesn;t work.

to post a comment

8 Comments(s)

Copy linkTweet thisAlerts:
@sibertNov 22.2022 — > @4539123#1648635 When I run it on that site, it works. But when I run it in my browser as my own webspage, it doesn;t work.

A wild guess is that the path to the javascript is wrong. And the regex may be invalid.

Copy linkTweet thisAlerts:
@cootheadNov 22.2022 —  @4539123#1648635

[i][color=#008]"FYI, I got the calculator code from a Coding Website.

When I run it on that site, it works. But when I run it

in my browser as my own webspage, it doesn't work."[/color]


If it works on a site, then post a link that site.

This will allow members to compare it with your posted

code and perhaps provide a solution for you.

Copy linkTweet thisAlerts:
@4539123authorDec 16.2022 — @coothead#1648638

Thank you for allowing me to post the link. Here it is...


Copy linkTweet thisAlerts:
@cootheadDec 16.2022 — Hi there 4539123,

I copied the code from that site and tested it locally without any problems.

Copy linkTweet thisAlerts:
@4539123authorDec 16.2022 — @coothead#1649260

Okay, I understand copy/paste, but a few questions...

1: what is text/css? what is app.css?
&lt;link rel="stylesheet" type="text/css" href="app.css"&gt;

2: can I add "id" tags to the following divs?

&lt;div class="nav"&gt;
&lt;h3&gt;Convert Words To Numbers&lt;/h3&gt;
&lt;p&gt;Enter the name:&lt;/p&gt;
&lt;div class="content"&gt;
&lt;input type="text"&gt;
&lt;button onclick="calculate()"&gt;Calculate&lt;/button&gt;
&lt;div class="result"&gt;&lt;/div&gt;
Copy linkTweet thisAlerts:
@cootheadDec 17.2022 — 1 This code...

<link rel="stylesheet" type="text/css" href="app.css">

...is incorrect.

It should be...

<link rel="stylesheet" href="app.css" media="screen">

There is no app.css file, at present.

If there was then it would be used to style the HTML.

2 You could add id attributes to the div elements, but

it begs the question, "why do you want to?"

Copy linkTweet thisAlerts:
@4539123authorDec 18.2022 — @coothead#1649264

1: why would I ad id tags to div elements?

A: in case I want to style them in css. But at the point of being so frustrated at not getting this to work, I will settle for a website that has no style as long as the calculator works.

2: where should the script element start and end? I tried adding it inside the head with no success. And then just before and after the input element with no success.

3: what to name the javascript? I have a folder "WebsiteB". Inside that folder is " index.html" and "css.css". And I have the src element to look for the JavaScript file named " javascript.js" ....and still nothing works.

I have programmed a nice looking site all in css. But the java I can't get to work still.

PS: tag = identifier; element = specific html "function"? I may have the terms switched I don't know.
Copy linkTweet thisAlerts:
@cootheadDec 18.2022 — Hi there 4539123,

check out the attachment that may be found here...

[url=https://www.mediafire.com/file/q70c038g7mbeope/numerology-calculator.zip/file][b]numerology-calculator.zip file[/b][/url]

It will show you how to apply the javascript and CSS files to the HTML file.



Help @4539123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 9.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @ddiebold17,
tipped: article
amount: 1000 SATS,

tipper: @Mqlinka19,
tipped: live stream
amount: 4900 SATS,

tipper: @Mqlinka19,
tipped: article
amount: 10 SATS,