/    Sign up×
Community /Pin to ProfileBookmark

Getting strings from Forms.

I know you could use:

[code]eval(form.screen.value);[/code]

(where “form” is the name of the form and “screen” is the name of a number input type in the form) to get whatever is in that field as a number, but how do you get it as a string?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@NedalsJul 10.2004 — string = document.formname.elementname.value; // always returns a string

eval not required.
Copy linkTweet thisAlerts:
@PyrusauthorJul 11.2004 — Thank you so much, that little thing was holding back my progress.
Copy linkTweet thisAlerts:
@fredmvJul 12.2004 — Oh, and you almost never need [font=courier]eval[/font]. It's quite costly for the interpreter, so avoid it. Instead to convert strings to numbers use one of the methods as described in [url=http://www.webxpertz.net/forums/showthread.php?t=27948]this thread[/url].
×

Success!

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