473,715 Members | 5,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

assigning values to a field in HTML document

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?

<HTML>
<SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
</SCRIPT>
<table ALIGN="center" border="2" width="100%" cellspacing="8"
cellpadding="0" >
<FORM action="" method="POST">
<Table border="0" width="75%" cellspacing="0" cellpadding="0"
align="center">
<TR>
<td COLSPAN="1" width="40%"> <LABEL for="firstname" >First name:
</LABEL>
</td>
<td COLSPAN="1">
<font face="Verdana" size="1" color="red">*</font>
<INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir">
</td>
</TR>
<TR>
<td COLSPAN="1" >
<LABEL for="lastname"> Last name: </LABEL>
</td>
<td COLSPAN="1">
<font face="Verdana" size="1" color="red">*</font>
<INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">
</td>
</TR>
<TR>
<td COLSPAN="1">Tex t Area: </td>
<td COLSPAN="1"> <TEXTAREA Name="Details" COLS="40",
ROWS="5" size="20">
<-- I want to see the concatenated value firstname + lastname as the
value of this text area -->
</TEXTAREA>
<BR>
</td> </TR> <TR>
</TR> <TR>
<td COLSPAN="1">
<font face="Verdana" size="1" color="red">*=R equired Fields</font>
</td>
</TR>
</TR>
<TR>
<td COLSPAN="1">
<INPUT type="submit" value="Send" >
<INPUT type="reset" >
</td>
</TR>
</FORM>
</TABLE>
</TABLE>
</HTML>

Jul 23 '05 #1
4 2285

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?

<HTML>
<SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
</SCRIPT>
<table ALIGN="center" border="2" width="100%" cellspacing="8"
cellpadding="0" >
<FORM action="" method="POST">
<Table border="0" width="75%" cellspacing="0" cellpadding="0"
align="center">
<TR>
<td COLSPAN="1" width="40%"> <LABEL for="firstname" >First name:
</LABEL>
</td>
<td COLSPAN="1">
<font face="Verdana" size="1" color="red">*</font>
<INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir">
</td>
</TR>
<TR>
<td COLSPAN="1" >
<LABEL for="lastname"> Last name: </LABEL>
</td>
<td COLSPAN="1">
<font face="Verdana" size="1" color="red">*</font>
<INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">
</td>
</TR>
<TR>
<td COLSPAN="1">Tex t Area: </td>
<td COLSPAN="1"> <TEXTAREA Name="Details" COLS="40", ROWS="5" size="20">
<-- I want to see the concatenated value firstname + lastname as the
value of this text area -->
</TEXTAREA>
<BR>
</td> </TR> <TR>
</TR> <TR>
<td COLSPAN="1">
<font face="Verdana" size="1" color="red">*=R equired Fields</font>
</td>
</TR>
</TR>
<TR>
<td COLSPAN="1">
<INPUT type="submit" value="Send" >
<INPUT type="reset" >
</td>
</TR>
</FORM>
</TABLE>
</TABLE>
</HTML>


document.getEle mentsByName("De tails").value =
document.getEle mentsByName("fi rstname").value +
document.getEle mentsByName("la stname").value

Jul 23 '05 #2
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.Detai ls.value = this.value + ' '
+ this.form.lastn ame.value;
">

[...] <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">
<INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani"
onchange="
this.form.Detai ls.value = this.form.first name.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>pl ay</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.Detai ls.value = this.value + ' '
+ this.form.lastn ame.value;
">
<br>
<LABEL for="lastname"> Last name: </LABEL>
<INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani"
onchange="
this.form.Detai ls.value = this.form.first name.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
Jul 23 '05 #3
Thanks, and yes I admit the frivolous posting style. It was the first
time I used a newsgroup to ask for help. Hope to repay by helping
others.

Jul 23 '05 #4
Thanks, gets me over the hump.

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
11308
by: Bhavin G | last post by:
Hi there , I am pretty new at javascripting and i am having this huge problem. I am using asp.net and C# webapplication. In my asp.net aspx file I have a place holder for taking an html table dynamically. I create a html table Time | Data1 | Data2 | Data3 type, in which the columns are not fixed, hence i am building it dynamically in c# code. now after i have the html table in the webpage, I want to give user to
1
6025
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
2
1861
by: Gawie Marais | last post by:
hi all, i have a form and would like to check two fields. if field 1 containes the letter 'c' and the other field contains 'undefined', then an error should apprear ina box on the screen. can anyone point me a piece of code ? Thanx,
1
2179
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not work. It works if the tags are <input type=radio...>. This line is OK:
3
1554
by: | last post by:
T.I.A. to whomever replys... I'm new to ASP. I'm reading input from a flat-file (not a DB) using a vbscript routine to display on an ASP form so that a user can update the info, submitting the form back to update the file. When I tried the html command: document.myformname.myfieldname.value = myvarname I get an object error msg. What is the correct ASP syntax for doing this?
5
2965
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate the tab key when the down arrow key is pressed. (we know there are other way to control focus flow but we use a lot of dynamic jsp fields, that will make the flow control a nightmare, we just want basic tabbing from the arrow key)
4
4665
by: sufian | last post by:
Below is the field where user enters his/her email address and the AJAX post request is sent to the server and the user sees the message: echo("<div id=\"message\" class=\"success\">Thank you! You have been successfully registered.</div>"); within 1.5 seconds. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
0
4099
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me with my problems. Now for my new little problem,I had a problem posting the values from checkbox fields to a database and thats the obstacle I overcame. Now the second part is my new problem is that I want that the next time that page loads for...
1
4927
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In the corresponding input field (text box) the user enters a new category order which gets stored in...
0
8821
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9340
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9103
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2118
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.