Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unanswered: jscript properties

    I am trying to hide a field when value in combo box lists changes.
    I am trying to find what is the property to hide the field because originally I got help to put this code together but it doesn't quite do what I need, as at the moment it disables or enables the field onchange event,but the field is enabled anyhow when I edit the page,so if I had value selected in the field where it disables the field and save it and edit it the field is not disabled because that only happens on onchange event and I still need it to be disabled whe edited,so I was thinking that hiding it would be a better idea alltogether,but once again have to find a way how to keep it hidden according to selection in the field when the field is edited as well.


    function showChoice()
    {
    if (document.myForm.Commissionable.value == 'Yes') {
    document.myForm.PropertyDetailsName.enabled=true;
    }
    else {
    document.myForm.PropertyDetailsName.enabled=false;
    }
    }

    I hope this makes sense and somebody can help.

    Regards and thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Code:
    function showChoice()
    {
    if (document.myForm.Commissionable.value == 'Yes') {
      document.myForm.PropertyDetailsName.enabled=true;
      document.myForm.PropertyDetailsName.style.visibility=visible;
      document.myForm.PropertyDetailsName.display=block;
      }
    else {
      document.myForm.PropertyDetailsName.enabled=false; 
      document.myForm.PropertyDetailsName.style.visibility=hidden;
      document.myForm.PropertyDetailsName.display=none;
      }
    }

  3. #3
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    not sure why there is that gap in visibility.....

  4. #4
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    thanks for your help, I am getting all sorts of errors at the moment but I will look at it first and see if this will take me anywhere.

    Have a nice weekend

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    damn, I duffed it...
    Code:
    function showChoice()
    {
    if (document.myForm.Commissionable.value == 'Yes') {
      document.myForm.PropertyDetailsName.enabled=true;
      document.myForm.PropertyDetailsName.style.visibility='visible';
      document.myForm.PropertyDetailsName.style.display='block';  
      }
    else {
      document.myForm.PropertyDetailsName.enabled=false;   
      document.myForm.PropertyDetailsName.style.visibility='hidden';
      document.myForm.PropertyDetailsName.style.display='none';  
      }
    }

  6. #6
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Actually I can't find anything about this error I am not sure if it's the property that is used is not correct or if the field name is incorrect,but then that doesn't make sense

    this is the line where the error is

    window.thisForm.CommissionRate.style.visibility=hi dden;

  7. #7
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    you might need to use quotes around it... actually the way I normally do it is to have a hidden and visible class defined in my stylesheet like this....

    Code:
    .Hidden
    {
        DISPLAY: none;
        VISIBILITY: hidden
    }
    .Visible
    {
        VISIBILITY: visible;
        DISPLAY: block;
    }
    Then I can just do this...
    Code:
    function showMemberAgreement() {
        var col = document.getElementById('MemberAgreement');
        if(col.className == 'Visible') {
            col.className = 'Hidden';
            col.style.display = 'none';
        }
        else {
            col.className = 'Visible';
            col.style.display = 'block';
        }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •