jQuery noobie can't make a checked checkbox show an alert.
- by Kyle Sevenoaks
I found this answer before, to fire an alert if the button is pressed but the checkbox isn't checked.
Why won't this work?
<input value="1" type="checkbox" name="salgsvilkar" ID="checkbox2" style="float:left;"
onclick="document.getElementById('scrollwrap').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /><label for="checkbox2" class="akslabel">Salgs og leveringsvilkår er lest og akseptert</label>
</span>
{literal}
<script type="text/javascript">
$(function() {
//checkbox
$("#checkbox2").click(function(){
//if this...
//alert("this")...
if($("#checkbox2").is(':checked'))
{
alert("im checked");
}
});
//button
$("#fullfor_btn").click(function(e){
if(!$("#checkbox2").is(':checked'))
{
alert("you did not check the agree to terms...");
e.preventDefault();
}
});
}
</script>
{/literal}
This on another .tpl:
<label></label>
<button type="submit" class="submit" name="{$method}" id="fullfor_btn" title="Fullfør bestillingen nå" value=""> </button>
What could be going wrong? The jQuery doesn't fire anything at all.