Results 1 to 2 of 2

Thread: Checkbox and Images...

  1. #1
    Join Date
    Jan 2007
    Thanked 0 Times in 0 Posts

    Default Checkbox and Images...

    Where can I find a script that would allow when someone hits a checkbox that an image that is associated with that checkbox appear in my <div> area?

  2. #2
    Join Date
    Mar 2006
    Illinois, USA
    Thanked 690 Times in 678 Posts


    This is basically the same as a mouseover/rollover image script.

    The action of a rollover image is based on the "onmouseover" property of an img tag:
    <img onmouseover=".....">

    For this, you want a similar property, that happens to be somewhere else on the page:
    <input type="checkbox" oncheck="...">

    The problem is that oncheck does not exist:
    So, you will need to fake it. There are two ways:
    --For both, you will need to use the property this.checked to see if it is checked (as opposed to unchecked):
    if (this.checked) { dothis(); }
    1. onclick: this works, but it triggers BEFORE the value is actually changed. So if you use onclick, you will need to find the opposite value for this.checked-- if !(this.checked) (because it has not switched yet).
    2. or, slightly simpler, onchange, then it would have already changed the value, so just if (this.checked)

    I think onclick will be a more immediate reaction, probably what you want.

    So, it should be roughly equivalent to:
    <input type="checkbox" onclick="if (!(this.checked)) { dothis(); }">
    Where "dothis();" is the same action as the rollover image in the normal script.

    That's some more relevant info if you want to look through it.

    I'm not sure what the best, most reliable approach is, though.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum


Posting Permissions

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