/    Sign up×
Community /Pin to ProfileBookmark

change name of form.input element

Hi,

I have forms which are printed on a page all with the same name and the same field names. I think that this is why when i submit the first form, it works, but when i submit the second form, it fails.

So, I would like to name the forms, and then submit them.

Additionally, I am thinking that I will have to change the field names on the form so that the are not confused with the other forms that would have the exact same names.

So, i am going to call javascript function on <form onSubmit, to change the names of the input fields from their dummy values,tothe names that the posted to page is expecting.

I will have the form name, and the input element’s name, how do i change the name ?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisDec 27.2006 — None of that is required. There is no technical reason why all forms cannot have the same name and all forms have fields which share names either between forms or within forms. The only "reason" for not doing this is to lessen your own confusion -- not the browser's. To make it easier on yourself -- without changing any names -- your onsubmit event handler should pass a generic reference for the current form to your code:

<form ...etc... onsubmit="return ValidateForm(this)">

This way, your code does not have to reference the form name at all. All field references within that form will be bassed upon the passed form object reference. You can also do the same thing for any field-level events. The event handler can pass a generic reference either for the field and/or for the form:

<input ...etc... onchange="return ValidateField(this)">

<input ...etc... onchange="return ValidateField(this, this.form)">
Copy linkTweet thisAlerts:
@mparker1113authorDec 27.2006 — Maybe you can help : http://www.edithrye.com/fudgery/

I have 2 forms, and they have the same name and variables.

When the 1st form is submitted, it works fine. But, the 2nd form always crashes, even though the variables appear to be filled in okay.

What do I need to do to get this ontrack? Any ideas
Copy linkTweet thisAlerts:
@so_is_thisDec 27.2006 — It doesn't seem that it is the duplicate field names which are the problem (your form names are not the same). It seems that the error is being detected by Google and, thus, it would seem it is something about the encrypted data in your form fields which Google does not like.
×

Success!

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