55 users online (1 members and 54 guests)  


  Results 1 to 15 of 15
  1. #1
    ghasembaghi's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Posts
    2

    getelement by id with Variant ID value

    i want to access a div in my html source:

    Code:
       
    <div id="6337" >
            Div-Content
    </div>
    ID value change when i refresh page.
    how can i access to this DIV with Variant ID value, with getelementbyID or other javascript method

    tnx all

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: getelement by id with Variant ID value

    There are a couple ways to do it. You can pass the id via a function parameter as below:
    Code:
    onclick="getID("6337");"
    or you can set the value at the top of the page, and pass the value via a variable to the javascript and the HTML div declaration

  3. #3
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: getelement by id with Variant ID value

    Hi there ghasembagh,

    the id and class selectors should not start with a number.

  4. #4
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: getelement by id with Variant ID value

    Thanks for catching that. I never use numbers in my classes and ids anyway (harder to remember what they are for), so didn't notice it.

  5. #5
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: getelement by id with Variant ID value

    Hi there jthayne,

    quite often it's 'team work' that gets the job done.

  6. #6
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: getelement by id with Variant ID value

    Amen to that.

  7. #7
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: getelement by id with Variant ID value

    I third it, especially the last couple weeks huh JT

    btw coot you bald old fart, you are not the only one. I lost mine April 5 of last year
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  8. #8
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: getelement by id with Variant ID value

    Hi there Dave,
    ...you are not the only one. I lost mine April 5 of last year
    Well, that was very careless of you.
    But looking on the bright side, just think of the barber bills that you will no longer have to pay.

  9. #9
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: getelement by id with Variant ID value

    Quote Originally Posted by coothead View Post
    just think of the barber bills that you will no longer have to pay.
    Quite tempting me.

  10. #10
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: getelement by id with Variant ID value

    Quote Originally Posted by coothead View Post
    Hi there Dave,

    Well, that was very careless of you.
    But looking on the bright side, just think of the barber bills that you will no longer have to pay.

    Careless does not even begin to describe it. As far as barber bills, I think the extra razors more than make up for any savings.
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  11. #11
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: getelement by id with Variant ID value

    ghasembaghi,

    Welcome to the forums, I hope your question was answered before I took it off topic.

    my apologies,

    Dave
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  12. #12
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: getelement by id with Variant ID value

    Hi there Dave,
    I think the extra razors more than make up for any savings.
    Well, if you're following in my footsteps then you've also got senile dementia and undesirable body odours with which to content.

  13. #13
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: getelement by id with Variant ID value

    Quote Originally Posted by coothead View Post
    Hi there Dave,

    Well, if you're following in my footsteps then you've also got senile dementia and undesirable body odours with which to content.

    Yeah, I did not want to get into my other problems. Glad I am not alone, but is that not just part of being a webmaster?


    I think it goes, coffee, cigs, broken marriage, bald head and body odor.
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  14. #14
    ghasembaghi's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Posts
    2

    Re: getelement by id with Variant ID value

    hello and tnx all
    ID Generate by server-side code and Random.
    there are many div in my html code.
    i can not access to server-side code.
    actually i want to remove Ads banner DIV from my blog by javascript code.
    i put this javascript in theme editor in my blog control panel.

  15. #15
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: getelement by id with Variant ID value

    Let me make sure I understand you then.

    You don't have any way to know the ID before the page loads.
    You don't have access to the HTML.

    From your description, I assume that your blog is hosted somewhere (like wordpress.org), and that they have an ad banner on their site that you do not like there and want to get rid of.

    If I am correct, please let me know where your blog is hosted. I will review over their TOS to make sure it is ok for you to disable the ads before I give you any code to do so.



Tags for this Thread