/    Sign up×
Community /Pin to ProfileBookmark

formname.fieldname.value is not a valid……

I posted a previous post about a scrabble style script that calculates the word value. I already got the problem I stumbled upon that time, but now I keep getting other error messages.

I create a html form that you fill out. After that my JS uses a new screen (not a new window, just a new screen. can’t really explain what I mean, try it for yourself) and can’t use the info from the form. Any idea how to run this script without problems?

And I tried using cookies before, but due to the fact that I stink at cookies and that not everyone uses them, I decided not to use them.

Here’s the script;

<html>
<head>
<title> Jeffrey Hendriks CSV1B
</title>
<head>
<body>
<form name = “Invoer”>
<input type = “text” name = “versleutel”> Voer een woord in, dit woord zal worden versleuteld.<br>
<input type = “text” name = “woordwaarde”> Voer een woord in, hiervan zal de woordwaarde worden uitgerekend.<br>
<INPUT TYPE=”button” VALUE=”Query uitvoeren” NAME=”startCheck” onClick=”encrypt()”>
<INPUT TYPE=”reset” VALUE=”Leeg maken” NAME=”maakLeeg”>
</FORM>
<script language=”javascript”>

<!–

function encrypt()
{
var codeerReeks = Invoer.versleutel.value;
var t = 0;
var teller = 1;
var begin = codeerReeks.length + 1;
var char = 0;
var ascii = new Array(codeerReeks.length);

do
{
char = codeerReeks.charCodeAt(t) + teller;
ascii[t]=char;
t++;
teller++;
}
while (teller < begin)

var t = 0;
var teller = 1;
var begin = codeerReeks.length + 1;

do
{
document.write(String.fromCharCode(ascii[t]));
t++;
teller++;
}
while (teller < begin)
woordWaarde()
}

function woordWaarde()
{

var woordwaardeReeks = Invoer.woordwaarde.value;
var text = woordwaardeReeks.toLowerCase();
var waardeKL = 0;
var zoekKL = woordwaardeReeks.match(/[aeijouy]/gi);
var waardeMKL = 0;
var zoekMKL = woordwaardeReeks.match(/[bcdfghklmnprstvwz]/gi);
var waardeS = 0;
var zoekS = woordwaardeReeks.match(/[xq]/gi);

if(zoekKL)
{
for(var l = 0; l < zoekKL.length; l++)
waardeKL = 1 * zoekKL.length;
}

if(zoekMKL)
{
for(var l = 0; l < zoekMKL.length; l++)
waardeMKL = 3 * zoekMKL.length;
}

if(zoekS)
{
for(var l = 0; l < zoekS.length; l++)
waardeS = 5 * zoekS.length;
}

var totaal = waardeKL + waardeMKL + waardeS;
document.write(totaal)
}

//eind verbergen javascript –>
</script>
</body>
</html>

I really hope someone can help me, because this isn’t my first time encountering this problem. I could never solve these problems, I just made a different script (or no script at all). But I know I shouldn’t let such a stupid problem get in my way, so help would be appreciated.

EDIT: I changed the naam=”woordwaarde” to name=”woordwaarde” . It doesn’t seem to help though….

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@RibeyedJan 27.2003 — hi, just having a quick look on the passing i spotted this error which would cause errors all the down your script:



<input type = "text" [B]naam[/B] = "woordwaarde"> Voer een woord in, hiervan zal de woordwaarde worden

This should be "name" and not "naam" this would cause this input box not to have a name to call, you are obviously trying to do stuff with the value from this textbox later in your code. If the textbox your calling doesn't exsist it will give you erros further down your code.

hope this help
Copy linkTweet thisAlerts:
@TheOnlyCreatureauthorJan 27.2003 — Well, it is nice you spotted that one. Alas, it's not the error. "naam" is dutch for "name". I never realized that I used the dutch names, but it works. Copy and paste the text in an empty html file, and you'll see that he DOES read the first (var codeerReeks = Invoer.versleutel.value? variable. It's the second one (var woordwaardeReeks = Invoer.woordwaarde.value? that doesn't work.

Here's a theory, yet a bit farsought; javaScript opens a new window (wich cannot be seen by us, it's something like a code only new screen) and destroys the old window (the one containing the text boxes). I've been fiddling with this theory for a time, but can't seem to quite put my finger on the how and why.
Copy linkTweet thisAlerts:
@TheOnlyCreatureauthorJan 27.2003 — You're both absolutely right, and if you check my first post you'll see I edited that part. But still, it won't budge. I'm sorry if I sounded like not taking the given advice. In fact, I tried that immediately when I read it. Unfortunately it won't work.

But hey, I'm a JS n00b and am now trying the document.forms[0].whatever.whatever part.

Thanks for the hint Dave, all help is greatly appreciated.

EDIT: and once more I have done the impossible: after the help of two people my script is still a no go!

I tried to use the document.forms[0].woordwaarde.value, but guess wat: he still says that its not an object.
×

Success!

Help @TheOnlyCreature 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...