Click here to Skip to main content
Rate this: bad
good
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 15-Oct-12 0:12am
Comments
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
good
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.
  Permalink  
v3
Comments
sivis sans at 15-Oct-12 5:32am
   
for jsf its very complicated to use , i will try my best .
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 OriginalGriff 480
1 Maciej Los 330
2 Richard MacCutchan 225
3 BillWoodruff 185
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2014
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