www.webdeveloper.com
Results 1 to 3 of 3

Thread: Assembling an element name within Javascript and enabling it.

  1. #1
    Join Date
    Dec 2010
    Location
    Fremont, CA, USA
    Posts
    8

    Assembling an element name within Javascript and enabling it.

    Hello,

    I have a table of about 18 columns. Contents of each cell have a unique name. The name is typically "rxfy" where x = row number and y = column number. Thus all cells in row no 4 will have r4fy where y will range from 1 thru 18. Ordinarily each cell is a field in a form and has an attribute of "disabled".

    In each row in the extreme left of the table is a "modify" button. On clicking the modify button in a row - say row no 4, I would like to change the attribute of all fields in row no 4 to disabled="false".

    Progress so far:

    I am able to activate a javascript function to which I pass the row number on which the modify button is clicked.

    What I am looking for:

    a For while loop where I move from 1 thru 18 and use this (or something similar) syntax ---- "document.getElementById("XXXXX").disabled=false;" where XXXXX will take values of r4f1 thru r4f18.

    Can anyone help me or point me in the right direction?

    Thank you in advance.

    Uttam

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Code:
    for( var i = 1; i < 15; i++ )
      document.getElementById( "r4f" + i ).disabled = false;

  3. #3
    Join Date
    Dec 2010
    Location
    Fremont, CA, USA
    Posts
    8
    Thank you very much - that worked very nicely.

    Uttam

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles