1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Apply css to a submit button which i can't access the code.

Discussion in 'CSS' started by fairuz.ismail, Nov 17, 2009.

  1. #1
    Hi,
    I have a common submit button code like this
    <input type="submit" />
    I need to apply css to this code but normally what I do is to add id or class to this button and then apply the css normally.
    This time, the only problem is I can't modify the code <input type="submit" /> because it came from other source. So just wondering is there a way to work through this?

    my question is,
    is there any way to apply ccs without an id or class name?
    can we add id or class name to an input element using javascript or something else?

    thanks
    SEMrush
     
    fairuz.ismail, Nov 17, 2009 IP
    SEMrush
  2. Kelly2

    Kelly2 Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can always try adding a style attr. to the input itself.

    <input type="submit" style="font-size:11px; background-color:#F00; color:#FFF;" />
     
    Kelly2, Nov 18, 2009 IP
  3. sanjaykrishna

    sanjaykrishna Guest

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Give them a class like this

    < input type="submit" class="submit-button">

    and design your css for the "submit-button" class. Hope it helps
     
    sanjaykrishna, Nov 18, 2009 IP
  4. Kelly2

    Kelly2 Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Someone didn't read through the entire post :p
     
    Kelly2, Nov 18, 2009 IP
  5. nehrav

    nehrav Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    here's an example, customize CSS for input as per your requirement

    input {
    	border:1px dashed #000; height:25px; background-color:#FF0000; color:#FFFFFF;
    	}
    HTML:
     
    nehrav, Nov 18, 2009 IP
  6. Kelly2

    Kelly2 Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    He has already stated that he doesn't have access to the stylesheet, and adding classes, attributies, etc. is out of the question.
     
    Kelly2, Nov 18, 2009 IP
  7. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    nehrav, if i apply css to input tag, it will apply the css to all inputs.. But i just want to apply a css style specifically to the submit button.

    btw kelly, i just dont have access to change the block of code directly. But i do have access to add external css to apply to the page in general, and i do have access to add html codes or what so ever around that specific block of code.

    p/s : the specific block of code that I mentioned is in fact a html form that come from external source.


    Any ideas anyone?
     
    fairuz.ismail, Nov 18, 2009 IP
  8. Kelly2

    Kelly2 Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    There are ways to get what you need done, but not without Ragex and stupid amounts of time.
     
    Kelly2, Nov 18, 2009 IP
  9. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    yeah, i'm thinking about using javascript to dynamically add the id attribute to that submit button. But since the button and the html form itself dont have a name attribute, it will be a hard work. =(
     
    fairuz.ismail, Nov 18, 2009 IP
  10. kk5st

    kk5st Prominent Member

    Messages:
    3,499
    Likes Received:
    377
    Best Answers:
    29
    Trophy Points:
    335
    #10
    In your stylesheet,
    input[type=submit] {
      ...
      }
    Code (markup):
    Older IEs will fail, but with the restrictions you have, some failure is expected. The alternative is to use javascript to add the class or id attribute. The js solution will fail for all who don't have js enabled.

    cheers,

    gary
     
    kk5st, Nov 18, 2009 IP
  11. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Thanks for the answer..
    odd it may seems, but i opt to use the javascript solution. The block of code that I want to apply css came from a javascript call. So before my code fail, the javascript call will fail first.

    So, we just assume here that javascript is enabled. DO you have any ideas on the javascript solution?
     
    fairuz.ismail, Nov 18, 2009 IP
  12. kk5st

    kk5st Prominent Member

    Messages:
    3,499
    Likes Received:
    377
    Best Answers:
    29
    Trophy Points:
    335
    #12
    Without more info, I can only guess at a method. I may be doing that anyway, as I'm not all that expert at js. ;)

    Upload a small test case to a public facing server, and give us a link.

    cheers,

    gary
     
    kk5st, Nov 18, 2009 IP