/    Sign up×
Community /Pin to ProfileBookmark

Oh How Annoying Values sent as string?

Why OH Why doesn’t this work…all I want it to do is add three to the current value of the text box.

I tried using “eval” but that doesn’t work either. Trouble is it’s parsing them together as if they were strings….

[code]
<HTML>
<HEAD>
<SCRIPT LANGUAGE=”Javascript”>
function doChange()
{
var num = myForm.length; // counts the number of form objects starting from zero. num= 7
for(i=0;i<num-2;i++)
{
myForm.elements[i].value+=3
}

}

</SCRIPT>
</HEAD>
<BODY BGCOLOR=”#0000ff” TEXT=”#FFFFFF”>
<FORM NAME=”myForm” STYLE=”margin-left:25px”>
myText 1: <INPUT TYPE=”text” NAME=”myText0″ value=”0″><P>
myText 2: <INPUT TYPE=”text” NAME=”myText1″ value=”1″><P>
myText 3: <INPUT TYPE=”text” NAME=”myText2″ value=”2″><P>
myText 4: <INPUT TYPE=”text” NAME=”myText3″ value=”3″><P>
myText 5: <INPUT TYPE=”text” NAME=”myText4″ value=”4″><P>
myText 6: <INPUT TYPE=”text” NAME=”myText5″ value=”5″><P>
<INPUT TYPE=”button” VALUE=”Start” onClick=”doChange()”> <INPUT TYPE=”Reset” VALUE=”Reset”>
</FORM>
</BODY>
</HTML>
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@NicodemasauthorMar 10.2003 — thanks Dave!

So [B]Number()[/B] converts a string into a number, I'll have to keep that in mind.
×

Success!

Help @Nicodemas 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.25,
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,
)...