/    Sign up×
Community /Pin to ProfileBookmark

More radio disabling on user select problems

i’m trying to include additional (looping) functionality to some code worked out on this thread: [URL=”http://www.webdeveloper.com/forum/showthread.php?p=1065718#post1065718″]http://www.webdeveloper.com/forum/showthread.php?p=1065718#post1065718[/URL]

the client added some choices to the form, so now i need to disable certain choices after an initial selection, then further narrow the choices based on the next selection. so i’ve created a second function, similar to the one on the prev. thread, called AttDisab:

[CODE]function AttDisab (val) {
this.d = function(el){
el.disabled=true;
el.checked=false;
if(el.parentNode.tagName == “label”)el.parentNode.className = ‘disabled’;}
this.en = function(el){
el.disabled=false;
if(el.parentNode.tagName == “label”)el.parentNode.className = ‘enabled’;
}
if(val===0){
en(document.OPHAConfReg.RegType[0]);
en(document.OPHAConfReg.RegType[1]);
en(document.OPHAConfReg.RegType[2]);
en(document.OPHAConfReg.RegType[3]);
d(document.OPHAConfReg.RegType[4]);
d(document.OPHAConfReg.RegType[5]);
d(document.OPHAConfReg.RegType[6]);
d(document.OPHAConfReg.RegType[7]);
}
if(val===1){
en(document.OPHAConfReg.RegType[4]);
en(document.OPHAConfReg.RegType[5]);
en(document.OPHAConfReg.RegType[6]);
en(document.OPHAConfReg.RegType[7]);
d(document.OPHAConfReg.RegType[0]);
d(document.OPHAConfReg.RegType[1]);
d(document.OPHAConfReg.RegType[2]);
d(document.OPHAConfReg.RegType[3]);
document.OPHAConfReg.RegType[4].disabled=false;
document.OPHAConfReg.RegType[5].disabled=false;
document.OPHAConfReg.RegType[6].disabled=false;
document.OPHAConfReg.RegType[7].disabled=false;
document.OPHAConfReg.RegType[0].checked=false;
document.OPHAConfReg.RegType[0].disabled=true;
document.OPHAConfReg.RegType[1].checked=false;
document.OPHAConfReg.RegType[1].disabled=true;
document.OPHAConfReg.RegType[2].checked=false;
document.OPHAConfReg.RegType[2].disabled=true;
document.OPHAConfReg.RegType[3].checked=false;
document.OPHAConfReg.RegType[4].disabled=true;
}
}[/CODE]

for this section of the form (all unecessary form element stripped in this example):

[code=html]<form id=”OPHAConfReg” name=”OPHAConfReg”>
<label>
<input value=”0″ type=”radio” name=”Attendance” id=”Attendance[0]” onclick=”AttDisab(0)” />
I will be travelling to the conference</label>
<br />
<label>
<input value=”1″ type=”radio” name=”Attendance” id=”Attendance[0]2″ onclick=”AttDisab(1)” />
I will be travelling to the conference</label>
<hr />
<label for=”RegType[0]”>
<input value=”RegMem” type=”radio” name=”RegType” id=”RegType[0]” onclick=”Disab(0)” disabled=”disabled” />
Regular Member</label>
<br />
<label for=”RegType[1]”>
<input value=”RegNonMem” type=”radio” name=”RegType” id=”RegType[1]” onclick=”Disab(1)” disabled=”disabled” />
Regular Non-member</label>
<br />
<label for=”RegType[2]”>
<input value=”StuMem” type=”radio” name=”RegType” id=”RegType[2]” onclick=”Disab(2)” disabled=”disabled” />
Student Member</label>
<br />
<label for=”RegType[3]”>
<input value=”StuNonMem” type=”radio” name=”RegType” id=”RegType[3]” onclick=”Disab(3)” disabled=”disabled” />
Student Non-Member
</label>
<hr />
<label for=”RegType[4]”>
<input value=”RegMem” type=”radio” name=”RegType” id=”RegType[4]” disabled=”disabled” />
Regular Member</label>
<br />
<label for=”RegType[5]”>
<input value=”RegNonMem” type=”radio” name=”RegType” id=”RegType[5]” disabled=”disabled” />
Regular Non-member</label>
<br />
<label for=”RegType[6]”>
<input value=”StuMem” type=”radio” name=”RegType” id=”RegType[6]” disabled=”disabled” />
Student Member</label>
<br />
<label for=”RegType[7]”>
<input value=”StuNonMem” type=”radio” name=”RegType” id=”RegType[7]” disabled=”disabled” />
Student Non-Member </label>
<input value=”Submit Form” type=”submit” />
<input value=”Clear Form” type=”reset” />
</form>
[/code]

[LIST=1]

  • [*]

    Why is the CSS not being applied?


  • [*]

    Why is the second instance of Regular Member (RegType[4]) always disabled?


  • [/LIST]

    Thanks in advance,

    –cz

    to post a comment
    JavaScript

    3 Comments(s)

    Copy linkTweet thisAlerts:
    @Sterling_IsfineFeb 13.2010 — [CODE]if(el.parentNode.tagName == "label")el.parentNode.className = 'disabled';}
    this.en = function(el){
    el.disabled=false;
    if(el.parentNode.tagName == "label")el.parentNode.className = 'enabled';
    }[/CODE]
    [/quote]

    The content of [I]tagName [/I] is uppercase.
    Copy linkTweet thisAlerts:
    @seezeeauthorFeb 13.2010 — Whoops. I had changed that during testing & forgotten to put it back. Fixing it solves the CSS problem (incidentally, I forgot to post the CSS above, but it's the same CSS as on the previously referenced thread), but does not fix the RegType[4] problem. It remains unselected no matter which Attendance[] is selected.

    Thanks for catching that,

    --cz
    Copy linkTweet thisAlerts:
    @seezeeauthorFeb 14.2010 — I found my error. The final line of the JavaScript s/b:[CODE]document.OPHAConfReg.RegType[3].disabled=true;[/CODE]Not:[CODE]document.OPHAConfReg.RegType[4].disabled=true;[/CODE]Thanks to all who sent suggestions.
    ×

    Success!

    Help @seezee spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...