Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

CSS & DHTML question

  • 12-06-2002 11:26AM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭


    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, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭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, Registered Users 2 Posts: 14,762 ✭✭✭✭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, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭Lemming


    Originally posted by donaloconnor


    Shouldn't u put </script> ?


    Typo


  • Advertisement
Advertisement