473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1452
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Div | last post by:
Im not to confident with updating vb6 programs to the new vb NET so im taking the long, safe way round and rewriting them - my pictures used are made in paint and are very bad resolution to keep...
2
by: Rob | last post by:
Does anybody see anything wrong ith this code? I want to have the elements disabled on load by default and it doesn't seem to work this way. Thanks Rob <script language="Javascript"> <!--...
4
by: omidmottaghi | last post by:
I need to disable/enable form elements in my form. the code i was developed works fine in FF, but in IE, its behaviour is very strange!! in the form, we have a lot of checkboxes, all of them...
3
by: John Dalberg | last post by:
I have a webpage with a form. Depending on user selections at the top of the page, the page will disable sections of the form. My plan is to put each section between a <div></div>. Each section...
2
by: dougawells | last post by:
Hi- I'm wanting to have a set of radio buttons disabled when a form is displayed, then if they check another specific radio button, those would become enabled. I've tried setting it via...
7
by: Varangian | last post by:
Hello I want to disable all the elements which are the childs of a Div element. I tried disabling the div element but it doesn't work... i.e. the child elements were not disabled what shal...
11
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
3
by: Sonnich | last post by:
Hi all! Say, I have <buttonor <input type="submit">, how do then disable them once they are clicked? I could not find the right thing on the net :-( S
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.