inserting value into next text field

Discussion in 'Javascript' started by Royse, Jun 19, 2005.

  1. Royse

    Royse Guest

    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
    Royse, Jun 19, 2005
    #1
    1. Advertising

  2. Royse

    Lee Guest

    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

    > }
    > }
    > }
    >}
    >///////////////////////////////////////////////
    >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, Jun 19, 2005
    #2
    1. Advertising

  3. Royse

    Royse Guest

    Thanks Lee
    Royse, Jun 19, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9iZXJ0IEhhbHN0ZWFk?=

    Problem with text when inserting into text box

    =?Utf-8?B?Um9iZXJ0IEhhbHN0ZWFk?=, Apr 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    406
    Somchai U.
    Apr 27, 2004
  2. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    7
    Views:
    694
    =?Utf-8?B?RHVzdGluIHZhbiBkZSBTYW5kZQ==?=
    Apr 10, 2006
  3. Arnold Peters
    Replies:
    1
    Views:
    427
    Paul Lutus
    Oct 20, 2004
  4. Deniz Bahar
    Replies:
    2
    Views:
    465
    Andrey Tarasevich
    Mar 9, 2005
  5. jr
    Replies:
    3
    Views:
    417
Loading...

Share This Page