#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    418
    Rep Power
    13

    VB Script: Text Object Value


    I'm not sure if this is possible but this is what I'm trying to accomplish.

    I have a dynamic number of HTML text boxes that I generate, and i is the iteration number.
    vb Code:
    <input type=""text"" name=""IntfNm"&i & """ size=""20"">


    next I'm trying to extract the value of the text field and write it to a file. This is where I'm having an issue.

    vb Code:
    intfNmVar ="IntfNm"&i
    objTextFile.Write(intfNmVar.Value)


    It doesn't like the last line. I'm extracting the value of the text field instead of the HTML text object.

    Any suggestions?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    418
    Rep Power
    13

    Solution


    So here is the solution to the problem.

    Instead of name, I use ID
    vb Code:
    <input type=""text"" id=""IntfNm"&i & """ size=""20"">


    and to retrieve the value I use the following code.
    vb Code:
    intfNmVar ="IntfNm"&i 
    objTextFile.Write(document.getElementById(intfNmVar).Value)
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    418
    Rep Power
    13

    Solution


    to make this work you need to use the ID instead of NAME in the input element.

    VB Code:
    <input type=""text"" id=""IntfNm"&i & """ size=""20"">


    Then use the method getElementByID

    VB Code:
    intfNmVar="IntfNm"&i
    objTextFile.Write(document.getElementById(intfNmVar).Value)
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,424
    Rep Power
    4539
    Thanks for posting your findings.
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain

IMN logo majestic logo threadwatch logo seochat tools logo