Iason

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromTaher Moinuddin
ToMe
Subject'I have a question, can you help'
Date22 September 2004 14:40
Hi,
 
I have created a web page that have text fields, drop-down list etc...for
the user to enter data.
 
I want to provide the user the summary of his enteries on 'multi line text
box'( front page call it as 'text area' ) on the same form as soon as he
click the last button .
 
I'm able to put the data of first text box in the first line of 'multiline
text box' but I'm struck at point how to put the data of next selected item
to the following line and continue further till the last text field data is
copied to the 'text area'.
 
Please can u help? by javascript or vbscript.
 
Regards,
taher
FromMe
ToTaher Moinuddin
SubjectRe: adding text to a textarea
Date22 September 2004 16:17
Taher,

First, get the values:

To get the value of a text field or password field or textarea or file input, you do this
theValue = document.forms['formName'].nameOfTextField.value;

To get the value of a checkbox, you do this
if( document.forms['formName'].nameOfCheckBox.checked ) {
 theValue = document.forms['formName'].nameOfCheckBox.value;
} else {
 theValue = '';
}

To get the value of a select box, you do this
theBox = document.forms['formName'].nameOfSelectBox;
theValue = theBox.options[theBox.selectedIndex].value;

To get the value of a radio button, you do this
theButtons = document.forms['formName'].nameOfRadioButtons;
theValue = '';
for( var i = 0; theButtons[i]; i++ ) {
 if( theButtons[i].checked ) {
   theValue = theButtons[i].value;
 }
}


Then put the values in the text area:

The first time, you will do something like this:
document.forms['formName'].nameOfTextarea.value = theValue;
The second time, you must do this (use += instead of =):
document.forms['formName'].nameOfTextarea.value += '\n'+theValue;


Hope this is what you need


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.