Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

CSS & DHTML question

Options
  • 12-06-2002 11:26am
    #1
    Registered Users Posts: 14,148 ✭✭✭✭


    Hi guys,

    I'm trying to get certain elements on a webpage disabled upon initial loading, but if a user picks option "blah" from a select menu, then an element is enabled (input type=text)

    problem is that whilst I can enable/disable to my hearts content using dhtml, I can't get elements to start disabled

    Here's the offending pieces of code:

    [i]** Style Sheet Entry **[/i]
    
    .hours
    {
            disabled:               true ;
    }
    

    [i]** WebPage **[/i]
    
    <script type="text/javascript">
    <!--
    
    function aboutOther(fieldVal, field)
    {
       if(fieldVal == 'other')
       {
          document.getElementById(field).disabled = false ;
          document.getElementById(field).value = '' ;
       }
       else
       {
          document.getElementById(field).value = '' ;
          document.getElementById(field).disabled = true ;
       }
    }
    
    //-->
    <script>
    
    ...
    ...
    
    <input type=text name="textfield" id="otherField" class="hours">
    


    Any thoughts?? :-/


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Can you just make the form element disabled in the HTML? Or does it have to be CSS based? Alternatively, use onLoad to set the element disabled?

    adam


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by dahamsta
    Can you just make the form element disabled in the HTML? Or does it have to be CSS based? Alternatively, use onLoad to set the element disabled?

    adam

    Well .. I'd rather keep all of the style control off the html itself and keep it all centralised in a css file. But I'll use onLoad if I have to. Not too bad that way.

    thanx dahamsta :D


  • Registered Users Posts: 14,761 ✭✭✭✭Winters


    Originally posted by Lemming
    [i]** WebPage **[/i]
    
    <script type="text/javascript">
    <!--
    
    function aboutOther(fieldVal, field)
    {
       if(fieldVal == 'other')
       {
    .....
    

    why not just use the: <script language="JavaScript"> ?


  • Closed Accounts Posts: 287 ✭✭donaloconnor


    Originally posted by Lemming


    //-->
    <script>




    Any thoughts?? :-/

    Shouldn't u put </script> ?


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by donaloconnor


    Shouldn't u put </script> ?


    Typo


  • Advertisement
Advertisement