473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Dynamic radiobuttons with labels in IE

ronnil
134 Expert 100+
Just found an annoying thing in IE

I'm working on this neat little form framework giving me easy-coded forms with some automatic made fields, for instance a boolean field.

My original idea was to make this with radiobuttons, and put them in a nice little table for the pretty looks
Expand|Select|Wrap|Line Numbers
  1. function Boolean()
  2. {
  3.    this.container = document.createElement('table');
  4.    var row = this.container.insertRow(this.container.rows.length);
  5.    var trueCell = row.insertCell(row.cells.length);
  6.    var falseCell = row.insertCell(row.cels.length);
  7.  
  8.    trueOpt = document.createElement('input');
  9.    trueOpt.type = 'radio';
  10.  
  11.    falseOpt = document.createElement('input');
  12.    falseOpt.type = 'radio';
  13.  
  14.    //set values and a bit other here
  15.  
  16.   /*
  17.   now, DHTML doesn't allow dynamic makings of <label> so instead i figured out to implement it like this
  18.   */
  19.  
  20.     trueLabel = '<label for='" + trueOpt.id + '">True</label>';
  21.     trueCell.appendChild(trueOpt);
  22.     trueCell.innerHTML = trueCell.innerHTML + trueLabel;
  23.  
  24.     //repeat with falsecell
  25. }
This ofc works great in FF, but by altering the innerHTML of the trueCell, IE suddenly won't treat the input as a radio option. event's don't fire or anything

I tried with putting
Expand|Select|Wrap|Line Numbers
  1. if(trueOpt.attachEvent)
  2.    trueOpt.attachEvent('onfocus',function(){trueOpt.checked=true});
  3.  
both before and after the innerHTML statement, but without luck.

Easy fix is to use a selectbox with two different values ;D but I pretty much want to implement radiooptions with labels later on...

guess you could make a label like this:
Expand|Select|Wrap|Line Numbers
  1. function Label(id,value)
  2. {
  3.    document.write('<label id="'+id'">'+value+'</label>');
  4.    return document.getElementById(id);
  5. }
  6.  
afterwards put this in trueCell with appendChild....

only problem is, this only works when the document is actually loaded i guess....

what do you guys think?
Jun 21 '07 #1
1 1188
ronnil
134 Expert 100+
heh... just struck me...

put the button and the label in two different cells... well duh! :)
Jun 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: pizzy | last post by:
PROBLEM: I CAN'T GET THE LAST RESUTS TO WORK CORRECTLY. I WOULD PROVIDE THE CODE (AND WILL IF REQUESTED). BUT IN MY OWN WORDS I AM TRYING TO HAVE THE FIRST FORM DYNAMICALLY CREATE INPUT BOXES...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: Kelly | last post by:
Hi Everyone I have a web application and all it basically does is ask for a user id and show a questionnaire. To create the questionnaire, I get the list of questions from the database and...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
1
by: Brad | last post by:
Thanks for taking the time to read my question. I have a table of data that has Date, Data and Category. I need to show, in a report, each Categories Data by Date. The Date has to be it's own...
4
by: Paul Bromley | last post by:
Hope someone can help me here. I thought this may be easy to find on Google, but I have not come across the answer. I have developed an application in VB.Net 2003 with a manifest file for...
0
by: chxant | last post by:
Hi, I'm trying to develop a webapplication with a dynamic panel. The first time the PanelResult is empty. After the user clicked on the Login button I want to show a couple of radiobuttons...
2
by: Lars | LKC-Net | last post by:
I have a dynamic web page, that handles a multiple choice test. All the RadioButtons are dynamic. When the user have filled out a page, and clicks Next, I have to retrive the ID's from the...
2
by: bharathi228 | last post by:
my code for retrieving values from database Dim da As New SqlDataAdapter("select parameter_name,parameter_units from sys_params", con) If con.State = ConnectionState.Closed Then con.Open()...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.