SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    aligning selects in javascript

    Hi im using the below snipit of code to add a row to my table and add a select box. All of which works fine, however how to I get the select to centre in the table its always left aligned?

    Code JavaScript:
    var cellRightSel = row.insertCell(1);
      var sel = document.createElement('select');
      sel.name = 'country[]';
      sel.setAttribute('class', 'text');
      sel.setAttribute("align","center");
      sel.options[0] = new Option('Select Country', 'select country');
      cellRightSel.appendChild(sel);

    Thanks
    CHris

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sel.setAttribute("align","center");

    There is no align attribute for select element-
    if there was, this would align the text inside the select element.
    Set the td cell align, or use css-
    td{text-align:center}

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, just the push I was looking for, sorted it in css


Bookmarks

Posting Permissions

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