Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    42
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Random number in img tag

    I need to write something like this: http://justsheri.com/webscripting/wsassignment/1049950/

    If you look at the code there is 52 of these <img src = './images/blank1.png'

    onClick='clickCard("qh",0)'/> where clickcard("numchanges", increments by 1) how is this done?

    Thanks
    Danny

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,589
    Thanks
    80
    Thanked 4,630 Times in 4,593 Posts
    Well, I wouldn't do it the way that was done.

    All you really need is <img src="blank.png" id="c1" onclick="card(this);"/>

    With "c1" through "c52".

    Then you keep the array of card name/images in JS instead of putting the card name into the layout. Makes it easier to code.

    But after that... Is this homework? I see that the page you referred us to is, so it makes me think you are doing homewerk as well.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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