From: HugeBob on
Hi All,

I'm trying to dynamically create a checkbox. Here's my code:

1. checkBox = document.createElement("input");
2. checkBox.setAttribute("type", "checkbox");
3. checkBox.name = "someBox";

This works fine in Firefox of course. But, IE balks on line 2 saying
it can't find a "type" attribute. Any clues as to what I'm doing
wrong?

From: Thomas 'PointedEars' Lahn on
HugeBob wrote:

> I'm trying to dynamically create a checkbox. Here's my code:
>
> 1. checkBox = document.createElement("input");
> 2. checkBox.setAttribute("type", "checkbox");
> 3. checkBox.name = "someBox";
>
> This works fine in Firefox of course. But, IE balks on line 2 saying
> it can't find a "type" attribute. Any clues as to what I'm doing
> wrong?

You are not telling the actual error message, IE and OS version, you may
have not declared `checkBox', and you are using setAttribute("type", ...)
when you should have used .type = ...

Bottom line: You did not read the FAQ before posting.

<http://jibbering.com/faq/#posting>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Laser Lips on
Just do this...

var checkBox = document.createElement("input");
checkBox.type="checkbox";
checkBox.name = "someBox";

Simples...*CHUK*

Graham

> 1. checkBox = document.createElement("input");
> 2. checkBox.setAttribute("type", "checkbox");
> 3. checkBox.name = "someBox";
>