Equivalent of .disabled = false in Mozilla?

R

Red_Indian

Hi

How do I accomplish the following functionality in Mozilla/ Firefox:

document.form.textbox.disabled = false

if I want to conditionally enable a text box that was disabled by default.

The above code works fine in IE, but doesn't in Mozilla. I have seen
somewhere the Mozilla equivalent of the same, but can't quite find it.

Also I would appreciate if you can point me to a solution (if any) that
works in both of them, without having to resort to checking the browsers
and executing seperate code.

Thanks in advance!
RI
 
D

Dennis Biletsky

Red_Indian said:
Hi

How do I accomplish the following functionality in Mozilla/ Firefox:

document.form.textbox.disabled = false

if I want to conditionally enable a text box that was disabled by default.

The above code works fine in IE, but doesn't in Mozilla. I have seen
somewhere the Mozilla equivalent of the same, but can't quite find it.

Also I would appreciate if you can point me to a solution (if any) that
works in both of them, without having to resort to checking the browsers
and executing seperate code.

Thanks in advance!
RI
I checked in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
Gecko/20040206 Firefox/0.8.
It works.
Here is piece of code.
<html>
<head>
<title>Test Page</title>
</head>
<form name="form123" id="form123" method="post">
<INPUT TYPE="text" NAME="catalog" SIZE="20">
<INPUT TYPE="button" NAME="button1" VALUE="disable"
onClick="form123.catalog.disabled=true">
<INPUT TYPE="button" NAME="button2" VALUE="enable"
onClick="form123.catalog.disabled=false">
</form>
</html>
 
R

Red_Indian

Dennis said:
I checked in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
Gecko/20040206 Firefox/0.8.
It works.

My mistake!!

I asked the wrong question... :p

I want to know the equivalent of ".innerHTML" in Mozilla

e.g.

document.getElementById('label1').innerHTML = "Test"
/
/
...
<p id="label1">


When you look at my code you'll see why I made the mistake of asking the
"wrong question" - I didn't realize that maybe the condition wasn't
being satified in the first place.

if (document.getElementById('label1').innerHTML != '')
{
document.request.textbox.disabled=false
....
}

Thanks once again!
"RI"
;)
 
L

Lasse Reichstein Nielsen

Red_Indian said:
I want to know the equivalent of ".innerHTML" in Mozilla

innerHTML works in Mozilla.
document.getElementById('label1').innerHTML = "Test"
/
/
...
<p id="label1">

I hope there is an </p> somewhere. Make sure your HTML is valid,
or that could be the cause of your problems.

if (document.getElementById('label1').innerHTML != '')

There is nothing here that shoudln't work in Mozilla/Gecko.
{
document.request.textbox.disabled=false

This might work, but I would recommend:
document.forms['request'].elements['textbox'].disabled = false;

/L
 
R

Red_Indian

Lasse said:
Make sure your HTML is valid,
or that could be the cause of your problems.

That tip helped me identify the problem. I ran the validator (and
amongst the other things :D) I found I was doing this right BEFORE the
code I sent in my earlier mail:

function refresh()
{
req_type=document.getElementById('type').value
.....

}

for a control NAMED (not the id) "type" :

<select name="type" onchange="refresh()">

While IE was forgiving this mistake and "realizing" I "meant" this:

document.myform.type.value (I don't know why I didn't use this in the
first place!!)

Mozilla wasn't (and rightly so ofcourse)

Anyways, I planned to run the HTML validator "at the end" of my project,
but the lesson I have learnt is it's never to early to validate your
HTML code. I guess I should get one of those editors with a built in
validator ;)

Thanks Lasee and everybody else!
RI
 
D

DU

Lasse said:
innerHTML works in Mozilla.

If the node to change is a text node, then innerHTML can be conveniently
replaced by W3C DOM 2 CharacterData attribute or a DOM Core attribtue
like assigning the childNodes[0].nodeValue; either way, such methods
which will work in Opera 7.x, MSIE 5+, Mozilla, Safari, etc..

DU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top