Martin Kurz wrote:
thanks for answer
But, all my question is based on a createElement
and setting its (new) attributes on the fly
where (setting attributes to a virtual element) :
- my IE fall down, errores, breaks, if type it's tried to set
whatever I can test
- my IE wants 'className' as attribute for new class
while my FF wants 'class' for same attribute
All was in my comemted example I give here back :
example :
<html>
<script type="text/javascript">
var ind = 0;
function newTextField(id) {
ind++;
var ntf = document.createElement('INPUT');
ntf.setAttribute('className','inpText'); // IE way
ntf.setAttribute('class','inpText'); // FF way
ntf.id = id+ind; // don't know if ID is an attribute ?
ntf.setAttribute('type','text'); // IE breaks function here
ntf.type = 'text'; // all as with this way
var val = 'new field id = '+id+ind;
ntf.setAttribute('value',val);
var place = document.createElement('P');
place.appendChild(ntf);
document.body.appendChild(place);
}
</script>
<style type="text/css">
..inpText { background:yellow; border:2px solid red; color:blue }
</style>
<button onclick="newTextField('nouv');">New Field</button>
</html>
Yes, type on input-element seems to be readonly.
Well, seems to be a not so good errorhandling on that IE-Version. But what do
you expect in setting a readonly-Attribute?
)
I try to tell to that new input element (createElement)
it's attribute would be one of types :
- text
- checkbox
- radio
- button
- submit
- reset
If I (and you, and they, we) can't set this type,
how to do to get some more radio-buttons, or check-boxes, or ... ?
[className]
And that seems to be an error in the FF-Implemantation. ....
if (document.getElementById(elementid).getAttribute("className")) {
// use setAttribute("className", "")
No, I am still in createElement
I can't get an attribute not yet set ...
document.getElementById(elementid).className = "green";
works in both browsers, IE and FF,
Yes, this way all work fine
document.getElementById(elementid).class = "green";
works in none, so FF seems to be a little bit inconsequent.
It seems to :-/