473,781 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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();
}
Jul 23 '05 #1
3 1485
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?


Jul 23 '05 #2
"Perttu Pulkkinen" <pe************ **@co.jyu.fi> wrote in
news:QV******** *****@read3.ine t.fi:
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?


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**********@i nvalid.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
1828
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 the size of the files to a minimum , so when im making forms, im enlarging my pictures - in vb6 this was fine but in vb NET they keep blurring and there are reasons why it is imperitive they remain exactly as they are - help me! how do i stop the...
2
2410
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"> <!-- window.onload(DisableElements());
4
2267
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 named like "xyz_np". in front of each checkbox, we have some fields, named "xyz" this is my JS code. after clicking on checkboxes:
3
33111
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 contains some collection of form elements. So if the user does not select some criteria, the related section of the form gets disabled. In a typical Windows type of application these elements get disabled and greyed out. What's the best way to do...
2
6317
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 window.document.formname.radiogroup.disabled="true"; (or false) - but that doesn't seem to work. I've seen this done with text boxes, but not with radio buttons. Can anyone give any help? Thanks
7
5958
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 I do am I missing something ?
11
2241
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 string "d" then I want to emable rblDebts which is disabled when the page loads. This part is not working (no errors) and I'm not sure why. Thanks. <script type="text/javascript" language="JavaScript"> <!-- Begin oldvalue = "";
3
3481
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
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.