Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unhappy Unanswered: read only and editable drop down lists help?

    I was hoping somebody would have an example for something similar I need to do here.

    I have a drop down box(Yes, no) if users select Yes that is suppose to bring up another drop down list with a list of choices.

    I was told by someone that the best way to go about is to create the second drop down list and make it read only, but make it editable when Yes from the previous drop down list is selected.



    I suppose java would script would do that, so I was hoping to see if somebody could help me with this, have no code at the moment.

    thanks and regards
    Last edited by zobernjik; 10-01-04 at 02:04.

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Okie.... when you write your second combo box include the attribute enabled="false".

    In your yes/no combo box add an on change event ( onchange="showChoices(); )

    Then include code similar to this in your header area of your page
    Code:
    function showChoice()
      if document.form.combo1.value = "Yes" {
        document.form.combo2.enabled=true;
      }
      else {
        document.form.combo2.enabled=false
      }
    }

  3. #3
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    I hate java and I don't know how to write java.
    Rokslide,thaks for your help I followed your suggestion i have place java cript in between java cript tags,created function I am calling onchange event, and then when I load the page it gives me an error "Line 39 Expected'}" which is basically an error in the middle of javascript function, and if I take the code out you helped me with the error disappears.

    And then if click the error off and try to select Yes from the combo box to execute the code i get an error "Object Expected" line 65" which is the last line of the function you helped me with, it is } and that is it.

    I have tried to do the same with this code

    function Populate_onchange()
    {

    if(document.getElementsByID("Commissionable").valu e=='Yes')
    {document.getElementsByID("PropertyDetailsName").s tyle.display='';}
    else
    {document.getElementsByID("PropertyDetailsName").s tyle.display='none';}
    }
    and I get an error that object doesn't support this property or method.


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


    All of this looks so simple but I can't make it work it is driving me nuts
    Last edited by zobernjik; 10-05-04 at 20:57.

  4. #4
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    I hate java and I don't know how to write java.
    Rokslide,thaks for your help I followed your suggestion i have place java cript in between java cript tags,created function I am calling onchange event, and then when I load the page it gives me an error "Line 39 Expected'}" which is basically an error in the middle of javascript function, and if I take the code out you helped me with the error disappears.

    And then if click the error off and try to selected Yes from the combo box to execute the code i get an error "Object Expected" line 65" which is the last line of the function you helped me with, it is } and that is it.

    I have tried to do the same with this code

    function Populate_onchange()
    {

    if(document.getElementsByID("Commissionable").valu e=='Yes')
    {document.getElementsByID("PropertyDetailsName").s tyle.display='';}
    else
    {document.getElementsByID("PropertyDetailsName").s tyle.display='none';}
    }
    and I get an error that object doesn't support this property or method.


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


    All of this looks so simple but I can't make it work it is driving me nuts

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    okie, change my function to work better with your other one....
    Code:
    function showChoice()
      var Comm = document.getElementsByID("Commissionable")
      var PropDet = document.getElementsByID("PropertyDetailsName")
      if Comm.value = "Yes" {
        PropDet.enabled=true;
      }
      else {
        PropDet.enabled=false; 
      }
    }
    and for your other version..
    Code:
    function Populate_onchange() {
      if(document.getElementsByID("Commissionable").value=='Yes'){
        document.getElementsByID("PropertyDetailsName").style.visibility='visible';
        document.getElementsByID("PropertyDetailsName").style.display='block';
      }
      else {
        document.getElementsByID("PropertyDetailsName").style.visibility='hidden';
        document.getElementsByID("PropertyDetailsName").style.display='none';
      }
    }
    let me know how it goes...

  6. #6
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Is there a limitation when it comes to using GetElementsByID as if I use it and see no reason why this code woudn't work it gives me an error that "Object doesn't support this property or method".

  7. #7
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    I don't think it is a limitation, just perhaps a problem with the way we are calling it. I'll have a bit more of a look for you...

    doh! try disabled = false instead of enabled = true and disabled = true instead of enabled = false.

    The property is disabled, not enabled.
    Last edited by rokslide; 10-10-04 at 23:42.

  8. #8
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Sorry to do this to you again and thanks once again.

    I forgot to say that i have tried those options and also forgot to say that If i call function showChoice() on selection of yes/no error is "document.myForm.Commissionable is not null or not an object"

    and if I call Populate_onchange()then error is "object doesn't support this property or method"

    I have spoken to my senior programmer who doesn't seems to be willing to help, so i am just compeletely stuck on something that was suppose to be easier.

    Cheers

  9. #9
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    can you post the completely generated html and javascript as an attachment? I'll look into it more...

  10. #10
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    thanks once again, this particular page is big and very customized so there are many functions,etc, so I have taken most of it out and left only fields that I need including some others not important when it comes to my problem.

    I have highlighted two functions and the code for the Commissionable field so you can see the way I am calling it.

    I have tried to take everything out correclty but in word it gets hard to follow the code so I have done the best I could, if this is messy I can send the complete code.

    Thanks a lot and regards
    Attached Files Attached Files

  11. #11
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    rather then posting the asp which I can't really use locally can you call up the page in a web browser and save the html and attach that?

  12. #12
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unhappy

    Pardon my ignorance, by that do you mean to hit F12 in order to preview this page and if that is it I can't do it,I mean I can but it errors, as my senior programmer is doing things in his very own way,unless you can suggest me a different way.

  13. #13
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    What I am meaning is that with all the vbscript in this thing that generated all the combos I can't really test the javascript and see what it is doing.

    Normally what you would do is call up the page in IE or Netscape and then view the source code and save the result.

  14. #14
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Here comes the source code of my edit page
    Attached Files Attached Files

  15. #15
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    One of your problems comes from the call to calculate amount in the window_onload event.

Posting Permissions

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