Tauqir wrote:
> I am trying to do a simple thing: I have these two text fields in an
> HTML form. I want to assign the concatenated value to a TEXTAREA. Can
> someone help me with the syntax?
Your HTML is horrible, please post valid, minimal code (get rid of the
table...) - it makes it much easier to offer help.
When do you want the concatenated value written? I've set it to happen
onchange. I guess you want "Details" to be firstname lastname? Or
lastname, firstname?
[...]
> <INPUT type="text" SIZE="30" NAME="firstname" VALUE= "Tauqir">
<INPUT type="text" SIZE="30" NAME="firstname" VALUE= "Tauqir"
onchange="
this.form.Details.value = this.value + ' '
+ this.form.lastname.value;
">
[...]
> <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">
<INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani"
onchange="
this.form.Details.value = this.form.firstname.value + ' '
+ this.value;
">
[...]
> <TEXTAREA Name="Details" COLS="40" ROWS="5" size="20">
<TEXTAREA Name="Details" COLS="40" ROWS="5" size="20"
readonly>Tauqir Ghani</TEXTAREA>
Setting it to readonly means that users can not edit it directly, but
it will still be submitted with the form.
Note that the onchange only fires when the text inputs lose focus, you
may want to set it to fire on some other event.
Fully functional code below:
<HTML>
<head><title>play</title>
</head><body>
<FORM action="" method="POST">
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" SIZE="30" NAME="firstname" VALUE= "Tauqir"
onchange="
this.form.Details.value = this.value + ' '
+ this.form.lastname.value;
">
<br>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani"
onchange="
this.form.Details.value = this.form.firstname.value + ' '
+ this.value;
">
<br>
<TEXTAREA Name="Details" COLS="40" ROWS="5" size="20"
readonly>Tauqir Ghani</TEXTAREA>
<br>
<INPUT type="submit" value="Send" >
<INPUT type="reset" >
</FORM>
</body></HTML>
--
Rob
|