/    Sign up×
Community /Pin to ProfileBookmark

help getting a value from a form

Hi everyone, this should be quite simple for someone who’s familiar with javascripting.

I’ll explain my question:
I have a page with a piece of html in the code as following:

[CODE]<center>
<form action=”voorwerp.html” method=”get”>

<input type=”hidden” name=”vw_type” value=”650″>
<input type=”hidden” name=”type” value=”store”>
<input type=”submit” value=”Back”>
</form>
</center>[/CODE]

I need to fetch that value of 650 from the form and check if it equals a number.
So like: if ([I]correct_command_to_fetch_that_value[/I] == 650){

I hope someone can help me out fast ?
Thanks!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PeentjeauthorJul 09.2009 — I need to add though that the name of the form is not specified...
Copy linkTweet thisAlerts:
@roadkillJul 09.2009 — You can access the value using this identifier:

document.forms[0].elements["vw_type"].value

This works too:

document.forms[0].elements[0].value

so the code you want is:

[code=php]if(document.forms[0].elements["vw_type"].value == 650) {
do_stuff();
}[/code]
Copy linkTweet thisAlerts:
@PeentjeauthorJul 12.2009 — Thanks a lot, exactly what I needed ?
×

Success!

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