vendredi 15 janvier 2016

Image click inside a labelfor doesn't check a checkbox inside a form element in IE

I have an image and I want to check a checkbox when a user clicks the image. This works fine as long as I'm not within a form element for all browsers. If I'm within a form element, IE doesn't check the box. I have to have the form element. I'm not able to create a fiddle script for this because fiddle doesn't allow form elements. Below is my HTML. Any help would be greatly appreciated!

<div id="div1">
    <label for="chk1" id="label1">
        <img src="http://ift.tt/1ZpJsNC" alt="alt for 1" title="title for 1" />
    </label>
    <input type="checkbox" id="chk1" value="one" />
    <span id="spn1">Check 1</span>
</div>

<form action="https://www.google.com" method="post" id="form1">
    <div id="div2">
        <label for="chk2" id="label2">
            <img src="http://ift.tt/1ZpJsNC" alt="alt for 2" title="title for 2" />
        </label>
        <input type="checkbox" id="chk2" value="two" />
        <span id="spn2">Check 2</span>
    </div>
</form>




Aucun commentaire:

Enregistrer un commentaire