/    Sign up×
Community /Pin to ProfileBookmark

Changing name on input field using JavaScript

Hi guys,

I have a field on my form:

<input name=”A” size=”30″ maxlength=”15″>

I want user entering more then 6 characters on this field to be “re-named” into

<input name=”B” size=”30″ maxlength=”15″>

when the user POST the form.

And also an other field value to change from

<input name=”TEST” value=”C”>

TO

<input name=”TEST” value=”D”>

Does anyone knows if this is possible?
Thanks for help.

Max

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorJan 16.2008 — when you submit data, you change the session. When you change the session you lose all the javascript changes, as javascript is a client-side language. My advice is to use a server-side application for that (php, asp...)
Copy linkTweet thisAlerts:
@mpace030authorJan 16.2008 — Hi KOR,

thanks for reply, but I actually need it just on that specific session, I need one input field that uses different "name" according to the lenght of caracthers added by end-user. On session level. Thanks a lot. Max.
Copy linkTweet thisAlerts:
@KorJan 16.2008 — Oh, I see...

Like this?:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="text/javascript"&gt;
&lt;script type="text/javascript"&gt;
function changeName(obj){
obj.name=obj.value.length&gt;6?'B':'A';
obj.form['TEST'].value=obj.value.length&gt;6?'D':'C';
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form&gt;
&lt;input type="text" name="A" size="30" maxlength="15" onkeyup="changeName(this)" onblur="changeName(this)"&gt;
&lt;input type="text" name="TEST" value="C"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@mpace030authorJan 16.2008 — Hi KOR,

impressive!

you are great! Thanks a lot, it works just fine.

Max
×

Success!

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