468,104 Members | 1,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,104 developers. It's quick & easy.

The most trustable way of blurring/disabling elements

What si the best and MOST BROWSERCOMPATIBLE 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(wich would looked natural
pair to removeAttribute) so I used disabled = "disabled" instead.
function bluron(form,ele)
{
document.forms[form].elements[ele].style.backgroundColor = "silver";
document.forms[form].elements[ele].blur();
if(document.forms[form].elements[ele].getAttribute("disabled") == false )
{ document.forms[form].elements[ele].disabled = "disabled" }

}
// ***********************************************
function bluroff(ele)
{
if(document.forms[form].elements[ele].getAttribute("disabled") != false )
{ document.forms[form].elements[ele].removeAttribute("disabled") }
document.forms[form].elements[ele].style.backgroundColor = "white";
document.forms[form].elements[ele].focus();
}
Jul 23 '05 #1
3 1310
What I found with google was something similar to this:

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

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

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

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

function bluron(ele)
{ document.form.ele.disabled= true}
function bluroff(ele)
{ document.form.ele.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?


Jul 23 '05 #2
"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote in
news:QV*************@read3.inet.fi:
function bluron(ele)
{ document.form.ele.disabled= true}
function bluroff(ele)
{ document.form.ele.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?


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.
Jul 23 '05 #3

"Duncan Booth" <du**********@invalid.invalid> kirjoitti viestissš > 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.


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.


Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rob | last post: by
4 posts views Thread by omidmottaghi | last post: by
3 posts views Thread by John Dalberg | last post: by
2 posts views Thread by dougawells | last post: by
7 posts views Thread by Varangian | last post: by
11 posts views Thread by shankwheat | last post: by
3 posts views Thread by Sonnich | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.