By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

radio button/check box selecting default problem DOM2

P: n/a
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

Nov 28 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
su***************@gmail.com wrote:
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';
[...]
--
Rob
Nov 28 '05 #2

P: n/a
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

Nov 28 '05 #3

P: n/a
su***************@gmail.com wrote:
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?
--
Rob
Nov 28 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.