inserting value into next text field

R

Royse

Hi Group
I'm trying to get the value from a select and place it into some text
fields.
all these fields have the same name.
when a user enters the page all fields are empty
Then, when they click on one of the options I want it to fill the first
field, then when they click on another option it should fill the second
and so on.
this is the script
//////////////////////////////////////////////////
function insert() {

counter = document.form1.LastCols.selectedIndex;
for( var i=0; i<document.forms.length;i++){
for( var j=0;j<document.forms.elements.length;j++) {

if(document.forms.elements[j].type == "text" &&
document.forms.elements[j].value == "" ) {



document.forms.elements[j].value =
document.form1.LastCols.options[counter].value;

}
}
}
}
///////////////////////////////////////////////
What this does is fill all text fields with whatever is clicked first,
What I need is to fill them incrementally
Any suggestion are well appreciated
Royse
 
L

Lee

Royse said:
Hi Group
I'm trying to get the value from a select and place it into some text
fields.
all these fields have the same name.
when a user enters the page all fields are empty
Then, when they click on one of the options I want it to fill the first
field, then when they click on another option it should fill the second
and so on.
this is the script
//////////////////////////////////////////////////
function insert() {

counter = document.form1.LastCols.selectedIndex;
for( var i=0; i<document.forms.length;i++){
for( var j=0;j<document.forms.elements.length;j++) {

if(document.forms.elements[j].type == "text" &&
document.forms.elements[j].value == "" ) {



document.forms.elements[j].value =
document.form1.LastCols.options[counter].value;


break; // otherwise, you continue to loop and add this value to other fields
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top