form field question

They have: 2 posts

Joined: Jan 2001

how can you change an input field within the form so that the entered text is altered by a given string before the user hits submit?

for example, if a user enters "ABC" into the input field, i want to know how the field "trial" be changed so that "DEF" is added to the end (trail=ABCDEF) before the user presses submit button within the form.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

more info...
will you always append with the same string?
or is there more logic behind it?.....
if (trial=="this") { trial = "this and that" }
if (trial=="jack") { trial = "jack and jill" }

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 2 posts

Joined: Jan 2001

i wanna use the same string, no matter what the user enters.

i tried a javascript code, but it didn't seem to reassign the value of "trial."

<script type="text/javascript"></script>

They have: 3 posts

Joined: Jan 2001

you'd access the field with

document.forms[0].trial.value'
so if you want to append to the string when submit is pressed try:

&lt;script&gt;
function poo() {
  document.forms[0].trial.value += 'DEF';
}
&lt;/script&gt;


<FORM onSubmit="poo()">
.
.
.
'
hope this helps

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.