javascript - function "buttons disabled" from beginning -
i have 3 radio buttons , 3 buttons each belong 1 radio button. want buttons enabled if according radio button checked.
my code works, if first click on radio button , start function. how can make function work, buttons disabled beginning?
the function looks
$("input:radio[name=kartenthema]").change(function() { if (this.value == "geburtenrate") { $("#karte_id").attr('src', 'kantone_interaktiv_geburten.svg'); $("#legende_id").attr('src', 'legenden/geblegende.png'); $("input[name=button1]").attr("disabled", true); $("input[name=button1]").addclass("disabledclass"); $("input[name=button2]").attr("disabled", false); $("input[name=button2]:enabled").removeclass("disabledclass"); $("input[name=button3]").attr("disabled", true); $("input[name=button3]:disabled").addclass("disabledclass"); } else if (this.value == "sterberate") { $("#karte_id").attr('src', 'kantone_interaktiv_sterbe.svg'); $("#legende_id").attr('src', 'legenden/sterblegende.png'); $("input[name=button1]").attr("disabled", true); $("input[name=button1]:disabled").addclass("disabledclass"); $("input[name=button2]").attr("disabled", true); $("input[name=button2]:disabled").addclass("disabledclass"); $("input[name=button3]").attr("disabled", false); $("input[name=button3]:enabled").removeclass("disabledclass"); } else if(this.value == "wanderung") { $("#karte_id").attr('src', 'kantone_interaktiv_wanderung.svg'); $("#legende_id").attr('src', 'legenden/wandlegende.png'); $("input[name=button1]").attr("disabled", false); $("input[name=button1]:enabled").removeclass("disabledclass"); $("input[name=button2]").attr("disabled", true); $("input[name=button2]:disabled").addclass("disabledclass"); $("input[name=button3]").attr("disabled", true); $("input[name=button3]:disabled").addclass("disabledclass") } } and radio buttons / buttons this:
<embed id="legende_id" src="legenden/geblegende.png" width="180" height="230" style="margin-left:30px" type="image/png" /> <h3> <input type="radio" class="radio" name="kartenthema" value="geburtenrate" checked="ckecked">geburtenziffer <input type="button" class="button" name="button2" value="animation" onclick="location.href='animation_geburten.html'"> <h3> <input type="radio" class="radio" name="kartenthema" value="sterberate">mortalität <input type="button" disabled="disabled" class="button" name="button3" value="animation" onclick="location.href='animation_mortalität.html'"> <h3> <input type="radio" class="radio" name="kartenthema" value="wanderung">interkantonale wanderung <input type="button" class="button" name="button4" value="animation" onclick="location.href='animation_wanderung.html'"> <br> <br> <input type="button" class="button" name="button1" value="kartogramm" onclick="location.href='kartogramm.html'" /> </br> </br> </input></input> </h3> </input></input> </h3> </input></input> </h3> i know can put disabled after input type, style doesn't change enabled disabled.
if (this.value == "geburtenrate") { change line , next 2 similar lines this:
if ($(this).val() == "geburtenrate") {
Comments
Post a Comment