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

    Join Date
    Jun 2003
    Posts
    418
    Rep Power
    14

    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. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    418
    Rep Power
    14

    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. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    418
    Rep Power
    14

    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,489
    Rep Power
    4540
    Thanks for posting your findings.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo