:: Forum >> Version 1 >>

Removing attributes from an HTML Object

Is there a way to remove an attribute from an HTML object.

I am still working on the checkbox thing. My direct problem is that when the "checked" property is set on an HTML input element, the checkbox always displays as checked (unless I missed something).

eg rendered code:

<input type="checkbox" name="foo" value="bar" checked="false|OFF"/>
still displays as a checked box.

So, is there a way in the object create function to say something along the lines of

if (this.getItemProperty("text")==mycheckedValue) {
so that the attribute is only set if the checkbox should be checked?

Also is there a way to have the attribute be removed? (eg when the checkbox is unchecked, and the html.refresh() is called the input is not rendered as checked)

I suppose I could manipulate the htmlObj._attributes property, but that is kind of hackish.

Or if this could be solved with some fundametal HTML knowledge, that would be even better.


Monday, May 10, 2004
I am going to publish a new release (0.3.2) in the next couple of days, which fixes the problem with attributes like CHECKED, DISABLED, READONLY. The null value will completely remove an attribute from HTML string.
Alex (ActiveWidgets)
Monday, May 10, 2004
Thanks, That will be great.

I have

obj.setAttribute("checked", function(){ return shouldBeChecked?"true":null; }

which gives me alert code of

<input type="checkbox" name="foo" value="bar" checked="null"/>  I suspect this is because a function returning null isn't the same as null itself.

I will eagerly await the 0.3.2 release.

If I haven't said so this week, this project is awsome!
Monday, May 10, 2004
The new 0.3.2 release is available now. It should allow clear checkbox with either false or null values in checked attribute.
Alex (ActiveWidgets)
Tuesday, May 11, 2004
Great!, thanks for implementing this so quickly.
Tuesday, May 11, 2004
Thanks Alex, that works perfectly
Tuesday, May 11, 2004

This topic is archived.

Back to support forum

Forum search