radio button/check box selecting default problem DOM2

S

sudhaoncyberworld

var tbl=document.createElement('TABLE');
var tr1=tbl.insertRow();
var td1=tr1.insertCell();
var rbtn1=document.createElement("<INPUT name='rbLop'>");// only with
INPUT and type='radio' not allowing me even to select
rbtn1.type='radio';
rbtn1.id='rbtn1';
//rbtn1.checked='checked';
//rbtn1.checked;
//rbtn1.checked='true';
var rbtn2=document.createElement("<INPUT name='rbLop'>");
rbtn2.type='radio';
rbtn2.id='rbtn2';
td1.appendChild(rbtn1);
td1.appendChild(rbtn2);
document.body.appendChild(tbl);

in above code i want the first button to be selected by default. but in
dom2 i am not able to do, but i am in bad need of it. please tell me
the alternate way and i hope there should be some ways. urgent
please............

http://www.w3.org/2001/12/DOM-Level-2-issues
http://www.w3.org/TR/DOM-Level-2-HTML/html.html
 
R

RobG

var tbl=document.createElement('TABLE');
var tr1=tbl.insertRow();
var td1=tr1.insertCell();
var rbtn1=document.createElement("<INPUT name='rbLop'>");// only with
INPUT and type='radio' not allowing me even to select

Manually break lines of code at about 70 characters to stop
auto-wrapping messing them up.

The syntax of your createElement statement is wrong:


var rbtn1 = document.createElement('input');
rbtn1.name = 'rbLop';

rbtn1.type='radio';
rbtn1.id='rbtn1';
//rbtn1.checked='checked';
//rbtn1.checked;
//rbtn1.checked='true';

Third time lucky... almost

rbtn1.checked = true;

var rbtn2=document.createElement("<INPUT name='rbLop'>");

var rbtn2 = document.createElement('input');
rbtn2.name = 'rbLop';


[...]
 
S

sudhaoncyberworld

Hi

That is also not working , i am using IE 6 and as i said above if i
create radio button with following code i am not able to select any
button, is it working for u

function test1()
{
var tbl=document.createElement('TABLE');
var tr1=tbl.insertRow();
var td1=tr1.insertCell();
var rbtn1=document.createElement("input");
rbtn1.name='rbLop';
rbtn1.type='radio';
rbtn1.id='rbtn1';
//rbtn1.checked='checked';
//rbtn1.checked;
rbtn1.checked=true;
var rbtn2=document.createElement("input");
rbtn2.name='rbLop';
rbtn2.type='radio';
rbtn2.id='rbtn2';
td1.appendChild(rbtn1);
td1.appendChild(rbtn2);
document.body.appendChild(tbl);
}

also pl go thru w3 issue link which is added by me
 
R

RobG

Hi

That is also not working , i am using IE 6 and as i said above if i
create radio button with following code i am not able to select any
button, is it working for u

function test1()
{
var tbl=document.createElement('TABLE');
var tr1=tbl.insertRow();

You should specify the location to insert the row:

var tr1=tbl.insertRow(tbl.rows.length);

var td1=tr1.insertCell();

And the cell:

var td1=tr1.insertCell(tr1.cells.length);

var rbtn1=document.createElement("input");
rbtn1.name='rbLop';
rbtn1.type='radio';
rbtn1.id='rbtn1';
rbtn1.checked=true;

That works in Mozilla, and should work in IE as far as I can tell, but
setting the defaultChecked works in both:

rbtn1.defaultChecked = true;


[...]
also pl go thru w3 issue link which is added by me

Which of the 25 issues do you think is relevant?
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top