473,224 Members | 1,362 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,224 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 1449
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
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.