Click here to Skip to main content
11,715,160 members (63,949 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Javascript JSF
Hello ,

function validateRelationshipGender() {
        var gender, genderForm;
        gender = document.getElementById("NewUser:ContactPersonGender").value;
        genderForm = document.getElementById("NewUser:ContactPersonGender").disabled = true;
        if (gender == "Male" || gender == "Female") {
            genderForm = document.getElementById("NewUser:ContactPersonGender").disabled = false;
Posted 14-Oct-12 23:12pm
Aman.A at 15-Oct-12 5:15am
do you want us to read the code and somehow read your mind as to what the problem could be? or would you be kind enough to tell whats the problem with the code?
AshishChaudha at 15-Oct-12 5:21am
and?? what the problem is??
sivis sans at 15-Oct-12 5:22am
actually i have two drop-down text boxes one is relationship(father,mother,son,daughter) and another one is gender(male ,female) , while i selecting relation ship father it automatically changed to male , and for mother as female (those process comes from bean) it will take 3 seconds , within 3 seconds i want disable and enable gender text box , using JS code using "onselect" event,

i tried but its not working , the above code is for disable and enable gender box but its not working for me , i m using JSF 1.0 version ,is this possible to do ?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I would recommend using jQuery, it makes JavaScipting easier to write and read:

To disable a control using jQuery use the attr() function passing in the attribute as the first parameter and value as the second.

$("#ddlc").attr("disabled", true);

where ddlc is the id of the control (which in my case is ASP.NET and in yours probably JSF):

<asp:dropdownlist id="ddlc" runat="server" clientidmode="Static"></asp:dropdownlist>

For detailed jQuery documentation refer: jQuery[^]

Please let me know if this doesn't work for you and I will remove this solution.
sivis sans at 15-Oct-12 5:32am
for jsf its very complicated to use , i will try my best .
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

$('#dropdown1').attr('disabled',true) for disable dropdown
$('#dropdown1').attr('disabled',false) for enable dropdown

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 495
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 775
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320

Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100