How to remove an element?

D

DL

Hi,

I have something like this:

var cb = new Ext.form.Combox( {
xtype: 'combo',
id: 'mybox'
....
});

which works just fine. However, in the later flow when the field
associated with the combox is no longer used I'd like to destroy the
box (it looks like cool effects).
The attempt of resetting the cb var to null did not help {cb=null} and
the attempt of removing the 'mybox' element didn't help neither
{var f = document.forms['myfrm']; var r =
document.getElementById('mybox'); f.removeChild(r);}

Simply put, it's like this:
Initially,
<input type="text" id="title"> {the combox here}
Later,
the <input type="text" id="title"> is removed or made invisible, so it
now looks like this
{the combox here}
and of course the above {the combox here} is unnecessary and it looks
bad.

Could you help? And please let me know if I haven't explained the
question clearly.

Thanks in advance.

P.S.
Testing browser is Firefox 3.5 and I'm using Firebug as well for
debugging.
 
G

Garrett Smith

Hi,

I have something like this:

var cb = new Ext.form.Combox( {
xtype: 'combo',
id: 'mybox'
...
});

which works just fine. However, in the later flow when the field
associated with the combox is no longer used I'd like to destroy the
box (it looks like cool effects).

You're asking for help on what looks to be an Ext-js widget.

To answer that, one would need to be familiar with the API for that widget.

This NG is about discussing javascript, mainly, though not exclusively,
as it pertains to web scripting. That is not how to use a particular
library, but more on things such as found in the FAQ:

http://jibbering.com/faq/

- which is far from complete, but covers a few important core topics
such as Functions, Dates, and Numbers.
The attempt of resetting the cb var to null did not help {cb=null} and
the attempt of removing the 'mybox' element didn't help neither
{var f = document.forms['myfrm']; var r =
document.getElementById('mybox'); f.removeChild(r);}

Why would setting cb = null remove cause any elements to be removed?

Garrett
 
D

DL

I have something like this:
var cb = new Ext.form.Combox( {
xtype: 'combo',
id: 'mybox'
...
}); ....
The attempt of resetting the cb var to null did not help {cb=null} and
the attempt of removing the 'mybox' element didn't help neither
{var f = document.forms['myfrm']; var r =
document.getElementById('mybox'); f.removeChild(r);}

Why would setting cb = null remove cause any elements to be removed?

Garrett

You're right, I posted the js library forum as well this generic js NG
in the hope of a quicker solution... and yes, the attempt of setting
cb = null was silly.
 
S

SAM

Le 6/19/10 7:08 PM, DL a écrit :
Hi,

I have something like this:

var cb = new Ext.form.Combox( {
xtype: 'combo',
id: 'mybox'
...
});

which works just fine. However, in the later flow when the field
associated with the combox is no longer used I'd like to destroy the
box (it looks like cool effects).
The attempt of resetting the cb var to null did not help {cb=null} and
the attempt of removing the 'mybox' element didn't help neither
{var f = document.forms['myfrm']; var r =
document.getElementById('mybox'); f.removeChild(r);}

var r = document.getElementById('mybox'); r.parentNode.removeChild(r);
r = document.getElementById('title'); r.parentNode.removeChild(r);

and so on ..

function suppress(elemtId) {
elentId = typeof elemtId == 'string'?
document.getElementById(elemtId) : elemtId;
elemtId.parentNode.removeChild(elemtId);
}

suppress('title'); suppress('mybox');

or, if title is in 2nd position in the form named 'myfrm' :
suppress(document.forms['myfrm'][1]);
suppress(document.forms['myfrm'][1]);
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top