SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Target input text fields by name?

    I have some code which is not created by me. It comes from a credit card service. The text input fileds for cc number, expiry date month/Year and CCV all have the same class. They do have different names.
    I need to change the width of the month / year fileds so that the fit next to each other. A little more CSS may be needed too. The problem is they all have the same class so I can't use that to affect only 2. Can I use the name?

    Code:
    <td>
    <input class="intra-field-label" type="text" name="expiry[month]" maxlength="2" value="" size="2">
    /
    <input class="intra-field-label" type="text" name="expiry[year]" value="" maxlength="2" size="2">
    </td>
    Also even if I do change the size of all of them they change back when they ge focus. What causes that and how do I fix it?
    If you want to see it in action go here (no I did not design it!) http://www.smyrnaheroesgala.com/prod...ontribute-100/
    Add it to the cart, proceed to checkout and look at the bottom of the checkout page.
    Please click remove for the product when you leave

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The class attribute can have multiple class names within the quotes just separate them by a space. For example

    class="intra-field-label removespacing"

  3. #3
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,801
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    this looks like a job for the attribute selector (If you dont need to support IE6) !

    try:
    input[name~=year]{...}
    or
    input[name=expiry\[year\]]{...}


Tags for this Thread

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
  •