/    Sign up×
Community /Pin to ProfileBookmark

accessimg a form element elsewhere

Hi,

Let’s say I have a form with id = “ABC” and in this form there is an input type text field called “name”. The question is “how can I access this field/element in other forms? I have tried the following 2:

variable = ABC.elements[“name”];
variable = document.ABC.elements[0];

No luck! I am learning PHP, and need the correct syntax statement that would do it.

Thanks!

DL

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzFeb 27.2006 — Try this.
document.getElementById('ABC').elements["name"];
Copy linkTweet thisAlerts:
@datalineauthorFeb 27.2006 — Hi Kravvitz,

Thanks for the reply! I've tried it; no luck!

May be I should try and explain what I'm doing. It is along this line:

1) I have a form id "ABC" where a user is to enter "name" and "e-mail address", and selects either football or hockey. User then clicks submit.

2) Another form opens, and based on choice, will show a number of players for selected sport (football / hockey). User will select a number of players and click submit.

3) On this submit, the players selected will be inserted in a MySQL DB (using PHP), as well as name and e-mail address of user. These 2 pieces of information were entered in the original (first) form. Hence my problem: accessing a form's elements from other places.

I am step-by-step building this site, and got stump on this. If anyone can think of anything to get me over this, it would be much appreciated!

Thanks!

DL.
Copy linkTweet thisAlerts:
@KravvitzFeb 27.2006 — Could you provide a link tot he page in question?

You're not trying to access elements on a previous page are you?
Copy linkTweet thisAlerts:
@datalineauthorFeb 27.2006 — Hi K.

To answer your questions:

1) I am doing/building everything on my local machine. It's not out there on an ISP server yet.

2) Yes, that's what I'm trying to do: access elements on a previous page.

Thx!

DL
Copy linkTweet thisAlerts:
@KravvitzFeb 27.2006 — Ah! You can't do that with JavaScript.

[url=http://www.php.net/manual/en/language.variables.external.php]You need to use PHP. You can access the name/value pairs that were submitted via $_GET, $_POST, and $_REQUEST.[/url]
×

Success!

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