TextField();

Discussion in 'JavaScript' started by dean5000v, Feb 4, 2009.

  1. #1
    hey does anyone know any links to tutorials or anything to help me create textfeilds with javascript. i think the TextField();
    function is what i need but cnt find much on it.

    here is a site that has done it with ajax

    http://www.vistaprint.co.uk/vp/ns/studio3.aspx?pf_id=088&combo=909.104.2.13708|13708|137|0&uei=251&icparts=yes&ag=true&combo_id=6001&ssc=1&filter=9%3a10013||1%2c4%3a10003||1%2c3%3a10001||1&xnav=previews&rd=3&referer=
     
    dean5000v, Feb 4, 2009 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Simplest way to do that is this:
    
    var myTextField = document.createElement('input');
    myTextField.type = 'text';
    
    Code (markup):
    This simply creates the text field. You can add any properties you like, the same as you can add when using the <input> tag. Here are some examples:
    
    myTextField.id = 'myTextField';
    myTextField.name = 'myTextField';
    myTextField.style.width = '100px';
    etc, etc...
    
    Code (markup):

    Then, you need to append the text field to your page. Here's how you can append it to the body of your page:
    
    document.body.appendChild(myTextField);
    
    Code (markup):
    You can also use ajax to do that, there are also other ways of creating the field, but i suggest you get familiar with this method first.
     
    xlcho, Feb 5, 2009 IP
  3. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thankyou, i'll try that out.
    that made perfect sense :D
     
    dean5000v, Feb 5, 2009 IP
  4. Bruce_Davenport

    Bruce_Davenport Guest

    Best Answers:
    0
    #4
    ya tis works for sure...i hve used it before
     
    Bruce_Davenport, Feb 5, 2009 IP