The most trustable way of blurring/disabling elements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Perttu Pulkkinen

    The most trustable way of blurring/disabling elements

    What si the best and MOST BROWSERCOMPATIB LE way of making elements disabled
    for the user? Also considering different kind of elements: textfields,
    selects, radiobuttons and textareas. This is what I have had, its quite okay
    in IE but not good enough for Netscape.

    - I remember there was problem with setAttribute(wi ch would looked natural
    pair to removeAttribute ) so I used disabled = "disabled" instead.


    function bluron(form,ele )
    {
    document.forms[form].elements[ele].style.backgrou ndColor = "silver";
    document.forms[form].elements[ele].blur();
    if(document.for ms[form].elements[ele].getAttribute(" disabled") == false )
    { document.forms[form].elements[ele].disabled = "disabled" }

    }
    // *************** *************** *************** **
    function bluroff(ele)
    {
    if(document.for ms[form].elements[ele].getAttribute(" disabled") != false )
    { document.forms[form].elements[ele].removeAttribut e("disabled") }
    document.forms[form].elements[ele].style.backgrou ndColor = "white";
    document.forms[form].elements[ele].focus();
    }


  • Perttu Pulkkinen

    #2
    Re: The most trustable way of blurring/disabling elements

    What I found with google was something similar to this:

    function enable()
    { document.myform .myelement.disa bled = false }
    function disable()
    { document.myform .myelement.disa bled = true}

    Now that is lousy function interface. It should be SOMETHING like this:

    function enable(myform, myele)
    { document.myform .myelement.disa bled = false }
    function disable(myform, myele)
    { document.myform .myelement.disa bled = true}

    but this is not right, I think variables cannot be just put there? At least
    with something like this i get error
    "document.myfor m.myele has no properties. What I actually tried was:

    function bluron(ele)
    { document.form.e le.disabled= true}
    function bluroff(ele)
    { document.form.e le.disabled= false}

    because I couldn't change the interface from what I had earlier. I hope
    "form" as a word is not reserved in javascript namespace, because that is
    the name of all my forms (how creative).

    So what is right solution?




    Comment

    • Duncan Booth

      #3
      Re: The most trustable way of blurring/disabling elements

      "Perttu Pulkkinen" <perttu.pulkkin en@co.jyu.fi> wrote in
      news:QV_Pc.23$T O4.15@read3.ine t.fi:
      [color=blue]
      > function bluron(ele)
      > { document.form.e le.disabled= true}
      > function bluroff(ele)
      > { document.form.e le.disabled= false}
      >
      > because I couldn't change the interface from what I had earlier. I hope
      > "form" as a word is not reserved in javascript namespace, because that is
      > the name of all my forms (how creative).
      >
      > So what is right solution?
      >[/color]

      function bluron(ele) {
      ele.disabled= true
      }
      function bluroff(ele) {
      ele.disabled= false
      }

      If you already have the element you want to change, then the document and
      form are irrelevant.

      Comment

      • Perttu Pulkkinen

        #4
        Re: The most trustable way of blurring/disabling elements


        "Duncan Booth" <duncan.booth@i nvalid.invalid> kirjoitti viestissä > function
        bluron(ele) {[color=blue]
        > ele.disabled= true
        > }
        > function bluroff(ele) {
        > ele.disabled= false
        > }[/color]
        [color=blue]
        > If you already have the element you want to change, then the document and
        > form are irrelevant.[/color]

        I have already answer but You mix object reference and object name. Or in a
        way i mixed them when i used word "ele" wich sounds more like object
        reference but was a name. But also your approach is okay, but different.






        Comment

        Working...