/    Sign up×
Community /Pin to ProfileBookmark

how to add all the letters in a name to come up with a number between 1 & 9

Folks,

I am new to JavaScript. I am working on a numerological project and can’t get a name to reduce to one digit that is between 1 & 9. I also don’t know how to just add the consonants for one operation, and just the vowels for another.

Here is the script I have that is not quite working:

<html>
<head>
<title>Name Number</title>
<script language=”JavaScript”>
<!–
function calcNumber()
{
var yourname=(myform.yourname.value.toUpperCase());
var alphabet=”abcdefghijklmnopqurstuvwxyz”;
var consonant=”bcdfghjklmnpqrstvwxyz”;
var vowels=”aeiou”;
//var yournum;
var total=0;

alert(yourname);
for(i=0; i<yourname.length; ++i)
{
total += (yourname.charCodeAt(i)-65)%9+1
}
alert(total);
total+=””;
//alert(total.charAt(0));
yournum=0;
for(i=0; i < total.length; i++)
{
//alert(“digit#+(i+1+: “+total.charAt(?));
yournum+=eval(total.charAt(i));
//alert(“yournum: ” +yourname);
}
document.write(“This is your Name Number. It is the story of your life.” );
document.write (” It affects how you will write, produce, direct, and perform in the play called Life. “);
document.write (“This is not the complete picture of who you are. “);
document.write (“Look at the Personality Number and the Heart numbers for a fuller picture of who you are “);
document.write (“The combination of the name, personality, and heart numbers is how you interact with others. “);
document.write (“This is where your talents lie. Your name Number is ” +yournum);
}
//–>
</SCRIPT>
</head>
<body bgcolor=”beige”>

<p>
<form name=”myform” action=”calcNumber()”>
Please write your name as it appears on your birth certificate.
<p>
<input type=”text” name=”yourname” maxlength= “50” size=”35″ value=””>
<p>
Send info by clicking on this button:
<p>
<input type=”button” value=”Submit” onClick=”calcNumber()”>
</form>
<p>
</body>
</html>

I’d really appreciate any help you care to offer.

Thanks,

Lionel

to post a comment
JavaScript

18 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Apr 17.2004 — like this:[code=php]<html>
<head>
<title>Name Number</title>
<script type="text/javascript">

function calcNumber() {

var lettr = 'v'
var yourname=(myform.yourname.value.toLowerCase());
var alphabet="abcdefghijklmnopqurstuvwxyz";
var consonant="bcdfghjklmnpqrstvwxyz";
var vowels="aeiou";
var conDit;
var total=0;

for(i=0; i<yourname.length; i++) {
conDit = (lettr == 'c') ? ("consonant.indexOf(yourname.charAt(i)) > -1") : ("vowels.indexOf(yourname.charAt(i)) > -1")
if(eval(conDit)) {
total += (yourname.charCodeAt(i)-65)%9+1
}
}

document.write("This is your Name Number. It is the story of your life. ");
document.write("It affects how you will write, produce, direct, and perform in the play called Life. ");
document.write("This is not the complete picture of who you are. ");
document.write("Look at the Personality Number and the Heart numbers for a fuller picture of who you are ");
document.write("The combination of the name, personality, and heart numbers is how you interact with others. ");
document.write("This is where your talents lie. Your name Number is "+ total);
}

</SCRIPT>

</head>

<body bgcolor="beige">

<form name="myform" onsumbit="calcNumber('c');return false;">
Please write your name as it appears on your birth certificate:
<input type="text" name="yourname" maxlength= "50" size="35" value="">
<input type="button" value="Submit" onClick="calcNumber()">
</form>

</body>
</html>[/code]
If you want to make it a 1-9 number, just modulo divide the number by 9, then add 1 ?
Copy linkTweet thisAlerts:
@lionel_berubeauthorApr 17.2004 — Many thanks for the suggestion. I just read the script and have to run, but I'll give it a try later today.

Lionel
Copy linkTweet thisAlerts:
@steelersfan88Apr 17.2004 — well give it a go, I am open to how you want it done, so I will modify if necessary ?
Copy linkTweet thisAlerts:
@lionel_berubeauthorApr 18.2004 — Steelerfan,

Again, thanks for the assist. Unfortunately, when I try to run the script you provided, I get a blank page. I don't know what the error is. Her is the script I use:

<html>

<head>

<title >Name Number </ title >

<script type ="text/javascript">

function calcNumber ()

{

var letter='v'

var yourname =( myform .yourname .value .toLowerCase());

var alphabet ="abcdefghijklmnopqurstuvwxyz";

var consonant ="bcdfghjklmnpqrstvwxyz";

var vowels ="aeiou";

var conDit

var total=0;

alert(yourname)

for( i=0;i<yourname .length ;i++)

{

conDit=(letter=='c' )?( "consonant.indexOf(yourname.charAt(i)) > -1" )? "vowels.indexOf(yourname.charAt(i)) > -1" )

if(eval( conDit ))

{

total+=(yourname .charCodeAt (i)- 65 )% 9+1

}

document .write ("This is your Name Number. Your name Number is " +total );

}

</SCRIPT>

</head>

<body bgcolor="beige">

<form name="myform" onsumbit="calcNumber('c');return false;">

Please write your name as it appears on your birth certificate:

<input type="text" name="yourname" maxlength= "50" size="35" value="">

<input type="button" value="Submit" onClick="calcNumber()">

</form>

If you want to make it a 1-9 number, just modulo divide the number by 9, then add 1

</body>

</html>


I also don't know why my original alphabet script is not running, eithere. Here is that script:

<html>

<head>

<title>Name Number</title>

<script language="JavaScript">

<!--

function calcNumber()

{

var yourname=(myform.yourname.value.toLowerCase());

var alphabet="abcdefghijklmnopqurstuvwxyz";

var consonant="bcdfghjklmnpqrstvwxyz";

var vowels="aeiou";

//var yournum;

var total=0;


alert(yourname);

for(i=0; i<yourname.length; ++i)

{

total += (yourname.charCodeAt(i)-65)%9+1

}

alert(total);

total+="";

//alert(total.charAt(0));

yournum=0;

for(i=0; i < total.length; i++)

{

//the line below is one that keeps giving me an error message, but I don't know //how to fix it

//alert("digit#+(i+1+: "+total.charAt(?));

yournum+=eval(total.charAt(i));

//alert("yournum: " +yourname);

}

document.write("This is your Name Number. It is the story of your life." );

document.write (" It affects how you will write, produce, direct, and perform in the play called Life. ");

document.write ("This is not the complete picture of who you are. ");

document.write ("Look at the Personality Number and the Heart numbers for a fuller picture of who you are ");

document.write ("The combination of the name, personality, and heart numbers is how you interact with others. ");

document.write ("This is where your talents lie. Your name Number is " +yournum);

}

//-->

</SCRIPT>

</head>

<body bgcolor="beige">

<p>

<form name="myform" action="calcNumber()">

Please write your name as it appears on your birth certificate.

<p>

<input type="text" name="yourname" maxlength= "50" size="35" value="">

<p>

Send info by clicking on this button:

<p>

<input type="button" value="Submit" onClick="calcNumber()">

</form>

<p>

</body>

</html>


If you have the patience to wade through any of the two scripts and have the solutions, I will appreciate the help.

Lionel
-----

Copy linkTweet thisAlerts:
@steelersfan88Apr 18.2004 — you are missing a bracket in your first script to end the for loop ? what is the difference in the objetc of the two scripts?
Copy linkTweet thisAlerts:
@lionel_berubeauthorApr 18.2004 — Steelersfan88,

Again, thanks for responding.

For the life of me, I can't find the missing bracket in the first script! I've been over and over the for loop and still don't see what is missing or where a brackett is missing.

To addressse the difference between the two scripts:

In the first script, I only wanted one number, a single digit between 1 and 9 that is the reduced total of the whole name. I thought a simple correction might clear up the script.

In the script you suggested, I originally thought it would deliver only the reduced value of the consonants and the reduced value of the vowels. However, I only saw one total, so I am confused.

Ultimately, I need three numbers, each between 1 & 9.

One for the whole name.

One for just the consonants.

One for just the vowels.


I suspect I'm taxing your patience. I really don't know how to proceed without someone who is clear, so I'm still stuck.

If you are still up to it, I'd appreciate help with the scripts.

Thanks again,

Lionel
Copy linkTweet thisAlerts:
@steelersfan88Apr 19.2004 — something like:[code=php]<html>

<head>

<title>Name Number</title>

<script type="text/javascript">

function calcNumber() {

var lettr;
var yourname=(myform.yourname.value.toLowerCase());

var alphabet="abcdefghijklmnopqurstuvwxyz";

var consonant="bcdfghjklmnpqrstvwxyz";

var vowels="aeiou";

var conDit;
var totalc=0;
var totalv=0;
var totala=0;

for(i=0; i<yourname.length; i++) {
lettr = 'v'
conDit = (lettr == 'c') ? ("consonant.indexOf(yourname.charAt(i)) > -1") : ("vowels.indexOf(yourname.charAt(i)) > -1")
if(eval(conDit)) {
totalv += (yourname.charCodeAt(i)-65)%9+1
}
}

for(i=0; i<yourname.length; i++) {
lettr = 'c'
conDit = (lettr == 'c') ? ("consonant.indexOf(yourname.charAt(i)) > -1") : ("vowels.indexOf(yourname.charAt(i)) > -1")
if(eval(conDit)) {
totalc += (yourname.charCodeAt(i)-65)%9+1
}
}

for(i=0; i<yourname.length; i++) {
totala += (yourname.charCodeAt(i)-65)%9+1
}

totalc = totalc % 9 + 1
totalv = totalv % 9 + 1
totala = totala % 9 + 1

alert("Vowels: "+ totalv)
alert("Consonants: "+ totalc)
alert("All: "+ totala)
}

</SCRIPT>

</head>

<body bgcolor="beige">

<form name="myform" onsumbit="calcNumber('c');return false;">
Please write your name as it appears on your birth certificate:
<input type="text" name="yourname" maxlength= "50" size="35" value="">
<input type="button" value="Submit" onClick="calcNumber()">
</form>

</body>
</html>[/code]
? of course it can be slightly reduced by using a function for loops, but it should be what you are after ?
Copy linkTweet thisAlerts:
@lionel_berubeauthorApr 19.2004 — Steelersfan88,

Your most recent contribution has been most helpful. However, there are still some bugs that get in the way.

Here is the case:

When I run the script for a name like "OTHELLO", I get the following alerts

OTHELLO


vowels 1

consonants 1

all 1

In the actual case (as you can see) is that Othello has three vowels and four consonants.

Here is what I need to script to do with that information.

Add the numeric value of all the vowels (o=6;e=5;o=6 to add up to 17 which reduces to 8 (1+7).

Add the numeric value of all the consonants (t=2;h=8;l=3;l=3, to add up to 16, which reduces to 7 (1+6).

Then to add both vowels and consonants for a total of (8+7=15), which is 6

I wish, in retrospect, I was clear in my first request, so you would see the problem with my script. I hope, however, that this is a clearer request and that you are still willing to help/assist me with this script.

Thank You,

Lionel
Copy linkTweet thisAlerts:
@steelersfan88Apr 19.2004 — I think I got it:[code=php]<html>

<head>

<title>Name Number</title>

<script type="text/javascript">

function calcNumber() {

var yourname=(myform.yourname.value.toLowerCase());

var alphabet="abcdefghijklmnopqurstuvwxyz";

var consonant="bcdfghjklmnpqrstvwxyz";

var vowels="aeiou";

var conDit;

var totalc=0;
var totalv=0;
var totala=0;

for(i=0; i<yourname.length; i++) {
conDit = "vowels.indexOf(yourname.charAt(i)) > -1"
if(eval(conDit)) {
totalv += (yourname.charCodeAt(i)-97)%9+1
}
}

for(i=0; i<yourname.length; i++) {
conDit = "consonant.indexOf(yourname.charAt(i)) > -1"
if(eval(conDit)) {
totalc += (yourname.charCodeAt(i)-97)%9+1
}
}

totalc = totalc.toString()
totala = totala.toString()
totalv = totalv.toString()

while(totalc.length > 1) {
var temp = new Array
for(var i=0;i<totalc.length;i++) {
temp[i] = totalc.charAt(i)
}
totalc = eval(temp.join('+')).toString()
}

while(totalv.length > 1) {
var temp = new Array
for(var i=0;i<totalv.length;i++) {
temp[i] = totalv.charAt(i)
}
totalv = eval(temp.join('+')).toString()
}

totala = (Number(totalv) + Number(totalc)).toString()

while(totala.length > 1) {
var temp = new Array
for(var i=0;i<totala.length;i++) {
temp[i] = totala.charAt(i)
}
totala = eval(temp.join('+')).toString()
}

alert("Vowels: "+ totalv)
alert("Consonants: "+ totalc)
alert("All: "+ totala)
}

</SCRIPT>

</head>

<body bgcolor="beige">

<form name="myform" onsumbit="calcNumber('c');return false;">
Please write your name as it appears on your birth certificate:
<input type="text" name="yourname" maxlength= "50" size="35" value="">
<input type="button" value="Submit" onClick="calcNumber()">
</form>

</body>
</html>[/code]
and Othello works ?
Copy linkTweet thisAlerts:
@JuuitchanApr 19.2004 — Have you never heard of casting out nines?
Copy linkTweet thisAlerts:
@steelersfan88Apr 19.2004 — not in that terminology, why do you ask, would it make the code much shorter (probably ?)
Copy linkTweet thisAlerts:
@JuuitchanApr 19.2004 — That's part of it.

I guess I'm more into math than you are.

I think I'd use ((x+8)%9)+1 for that. Let me test it with x=2:

((2+8)%9)+1

(10%9)+1

1+1

2

It seems OK.
Copy linkTweet thisAlerts:
@steelersfan88Apr 19.2004 — would it not be easier just to modulo divide by 9? Actually, I am very into math (surprising, huh?). I programmed calculators for my class, and long back when, when I was in middle school, I led my team by winning a regional math competition to the states 2 years in a row (we got 9th both years in the states ... out of 10/11 teams <-- one person can only go so far without the rest of the team)
Copy linkTweet thisAlerts:
@JuuitchanApr 19.2004 — You would have to change an answer of 0 to 9.

By the way, your alphabet has an extra "u" in it (after the "q").
Copy linkTweet thisAlerts:
@steelersfan88Apr 19.2004 — that can be removed, i just copied that from way back when. That wouyldn't be too difficult, just check if !total, total == 9. I never did see that though, pretty neat, but I think the OP wanted 0s to be 1, 1s to be 2s, rather than just making 0s, 9s ?
Copy linkTweet thisAlerts:
@lionel_berubeauthorApr 20.2004 — Steelerfan88,

Brilliant code work, regardless of what other solutions may work.

Wow!

Your solution is excellent! The names work just great!

I am truly, truly thankful.

Now I can get on with more of the grunt work, so to speak, as I get all the information together to interpret the numbers. (This is more the sort of level I usually function at.)

Again, I am most grateful for all your patience and excellent work!

Lionel
Copy linkTweet thisAlerts:
@steelersfan88Apr 20.2004 — well glad to help out, and to entertain you with an intelligent discussion that stayed at a calm pace, which shows that when two (or three ?) smart minds come together, solutions emerge. Is this a new branch of astrology that you get a number and from that they figure out your horoscopes? I'm interested!
Copy linkTweet thisAlerts:
@lionel_berubeauthorApr 20.2004 — Steelersfan88,

I'm working on a simple version of something called numerology, a very old divination system based on numbers thought to be based on the theories of Pythagoras.

When I complete the program, I'd be glad to send you a working version. I have to tell you, however, that this is going to take me some time. I am sure I will have a few more stumbling blocks to get through before I complete the project.

The process of coming up with a reading involves giving details about what each number from one to nine means for each part of the person's name, birthdate, and current year.

I think of the reading more as a psychological/emotonal/personality profile to assist with personal awareness and clarity about one's essential nature. In addition, the reading can give a person some idea of what the "vibe" is for the month, day, and year coming up. So, the reading could be helpful for a person to have some idea of what the emotional/psychological weather is going to be like for the immediate future.

And like preparing for the weather, one has choices about what to do when one knows what is coming. Always, one has choices, free will to decide how one is going to behave.

Mostly, I think of the reading as an entertaining and possibly informative perspective on one's life. As well, one can look at the reading a a working hypothesis--is the information accurate and helpful?-- that may shed light on what one is going through at any given time.

Numerology, like astrology, is a system that purports to shed some light on human motivation, behavior, and so on.

So, as I wrote earlier in this missive, when I am done, I'd be pleased to send along what gets created. Just let me know how to get in touch with you.

Again, thanks for all your help.

Lionel
×

Success!

Help @lionel_berube 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...