inserting value into next text field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Royse

    inserting value into next text field

    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.select edIndex;
    for( var i=0; i<document.form s.length;i++){
    for( var j=0;j<document. forms[i].elements.lengt h;j++) {

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



    document.forms[i].elements[j].value =
    document.form1. LastCols.option s[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

  • Lee

    #2
    Re: inserting value into next text field

    Royse said:[color=blue]
    >
    >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.select edIndex;
    >for( var i=0; i<document.form s.length;i++){
    > for( var j=0;j<document. forms[i].elements.lengt h;j++) {
    >
    > if(document.for ms[i].elements[j].type == "text" &&
    >document.for ms[i].elements[j].value == "" ) {
    >
    >
    >
    >document.for ms[i].elements[j].value =
    >document.form1 .LastCols.optio ns[counter].value;[/color]

    break; // otherwise, you continue to loop and add this value to other fields
    [color=blue]
    > }
    > }
    > }
    >}
    >///////////////////////////////////////////////
    >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
    >[/color]

    Comment

    • Royse

      #3
      Re: inserting value into next text field

      Thanks Lee

      Comment

      Working...