/    Sign up×
Community /Pin to ProfileBookmark

Quick question

Alright, so I have a bunch of hidden input tags that go something like this

<input type=”hidden” name=”1″ value=”30″>
<input type=”hidden” name=”2″ value=”34″>
<input type=”hidden” name=”3″ value=”47″>

so, to figure out the value of “1,” I would use newform.1.value

but the way stuff is set up, X equals a number – and that number is the name of a certain hidden input tag. kind of like in PHP how you can do $_POST[$x]
I hope that makes sense

I wanna do something like newform.x.value / newform. +x . value but I have no idea how you actually write that in JS

Thanks in advance! ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Jun 10.2008 — You want to access it using a variable?<i>
</i>var x = 1;
document.newform[COLOR=red][x][/color].value;
Copy linkTweet thisAlerts:
@Mauri824authorJun 10.2008 — You want to access it using a variable?<i>
</i>var x = 1;
document.newform[COLOR=red][x][/color].value;
[/QUOTE]

thanks, I just realized that what I was doing wrong was putting an extra period

( newform.['var' +x] ) but yeah, that's what I was trying to do

I was pretty close ?
×

Success!

Help @Mauri824 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 4.30,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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