www.webdeveloper.com
Results 1 to 6 of 6

Thread: Reading fabricated textbox.

  1. #1
    Join Date
    Sep 2007
    Posts
    22

    Reading fabricated textbox.

    My code starts in a loop, creates textboxes, the number of them dependant on available rows from an SQL query.

    How can I read them?
    The below code just errors out. Formdate[i] might be 0 to 6.
    <code>
    DateData = document.form2. + "D" + formdate[i] + .value ;
    </code>

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,343
    If you were to show the code on how your text boxes are created and what you are setting then someone might be able to give you an answer
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Sep 2007
    Posts
    22
    Ok. That makes sense.

    <input type="Text" id="D<%=Objrst1("id")%>" maxlength="25" size="25">

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,343
    Ok, what is that as a server-side?

    anyway, you are setting the id tag, each ID has to be unique but if you use the name tag, all the NAMES can be the same and you access that by using the document.getElementsByTagName("tagsName") where tagsName is the <input type="text" name="inputName" ... ...

    if you are going to use individual ID's then I would suggest that you have an array to contain your ID's and then build an array reference for them...

    Code:
    listOfId.push("D<%=Objrst1("id")%>");
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  5. #5
    Join Date
    Sep 2007
    Posts
    22
    Yes it is. I know there is a way to reference the textbox, I've used it before, but I cannot for the life of me remember how to do it.

    I could use a switch statement in a for next loop, then reference the object as below:
    DateData = document.form2.D1.value

    but accessed like this?
    DateData = document.form2." + someID + ".value

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,343
    getElementByName(elementName); // reads the form input elements that have a specific name reference. This returns an array of elements

    getElementsByTagName(theTageName); // reads a set of tags, example input, div, p, and so on

    getElementByClassName(cssClassRef); // reads any tag that has the matching class tag attribute set, not yet 100% compatible in some older browsers

    getElementById(idTagName); // reads a specific element by its unique ID tag name.

    if you google them, you will find how to use them effectively, note that the getElementsByClassName will require your code to have a workaround method in case it does not exist on the clients machine.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

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