/    Sign up×
Community /Pin to ProfileBookmark

Value of varying text fields

I’m building a shopping cart that can have one or many lines of items, each with a single text field displaying the Quantity of that line.

When a quantity is changed, I need to know what it was changed to.

Each text field does have a unique name which I’m successfully loading to a variable. With the variable knowing the name of the field, how do I load the value to another variable?

Essentially, where XXX is a changing field name, I’m trying to resolve:

var newvalue = document.cart.XXX.value

I’m stumbling on how to add the variable bearing the field name into the equation.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

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