ssh 6
New Member - function testfn(name)
-
var tbody = document.getElementById('hellospace').getElementsByTagName('tbody')[0];
-
var row = document.createElement('TR');
-
var cell1 = document.createElement('TD');
-
cell1.align="left";
-
cell1.style.height = "22";
-
cell1.style.width = "15";
-
cell1.valign = "middle";
-
cell1.className = "dwInfo";
-
var inp1 = document.createElement('INPUT');
-
inp1.type = "checkbox";
-
inp1.name = "collectionName";
-
inp1.value = name;
-
inp1.checked = "checked";
-
-
cell1.appendChild(inp1);
-
//cell2
-
var cell2 = document.createElement('TD');
-
cell2.style.height = "22";
-
cell2.align ="left";
-
cell2.className = "dwInfo";
-
cell2.innerHTML= name ;
-
row.appendChild(cell1);
-
row.appendChild(cell2);
-
tbody.appendChild(row);
-
-
}
-
All works find in firefox but in IE the checkbox property "checked" doesnt seem to be working. Problem:
This function testfn(name) is used to append a row whenever a particular conditions check is true. So here in firefox when the function executes, a row is appended and also the checkbox is checked. In IE the row is appended but the checkbox is not checked.
It would be great if anyone could suggest where the problem could be.
Thanks in Advance,
ssh.
12 40132 iam_clint 1,208
Recognized Expert Top Contributor
I don't know why, but if you append the input element to the document first,you can then set the checked value:
cell1.appendChi ld(inp1);
inp1.checked = "checked";
This also seems to be needed by Opera, and it
will apply the value in firefox,which doesn't care, just as well.
iam_clint 1,208
Recognized Expert Top Contributor
thats interesting never tried that.
ssh 6
New Member
I don't know why, but if you append the input element to the document first,you can then set the checked value:
cell1.appendChi ld(inp1);
inp1.checked = "checked";
This also seems to be needed by Opera, and it
will apply the value in firefox,which doesn't care, just as well.
hi!
I tried both the ways already but couldnt get it working in IE. Anyway Thank you very much.
I also tried checked = "true" but still it doesnt work in IE. Need to find some other way to get it checked ...
Regards,
ssh
acoder 16,027
Recognized Expert Moderator MVP
There are two solutions to this: - Set the defaultChecked property instead.
- Try
- inp1.setAttribute("checked","checked");
after appending as suggested by mrhoo
See this link.
ssh 6
New Member
There are two solutions to this:- Set the defaultChecked property instead.
- Try
- inp1.setAttribute("checked","checked");
after appending as suggested by mrhoo See this link.
Initially i used setAttribute but this 'setAttribute' doesnt work in IE7. It works only in ff.
Regards,
ssh
acoder 16,027
Recognized Expert Moderator MVP
Initially i used setAttribute but this 'setAttribute' doesnt work in IE7. It works only in ff.
Regards,
ssh
IE! Such a buggy browser!
Use the first option then: Atli 5,058
Recognized Expert Expert
Initially i used setAttribute but this 'setAttribute' doesnt work in IE7. It works only in ff.
Regards,
ssh
This works fine for me in IE7. -
<input type="checkbox" id="cb" />
-
<br />
-
<div onclick="javascript: getElementById('cb').setAttribute('checked', 'checked');">
-
Linkage
-
</div>
-
Atli 5,058
Recognized Expert Expert
For some weird reason the checked attribute can not be set before the input is appended to the cell.
So append it first and then check it.
I tested both var.checked and var.setAttribut e on my IE7 and they both work fine.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: John E |
last post by:
How do I get whether a checkbox is ticked in a form on a form's submission
(true or false)? How do I use the Request object in ASP?
|
by: Kurda Yon |
last post by:
Sorry for a very stupid question. Can you tell me what does the
following html source does if I press button "Send"? If I read this
code by Netscaspe from my local file system and then press "Send", I
see in my browser directory where the considered html source is
located. If I publish the given html source, open published page and
again press "Send" nothing changes... What I want to do, is to know
what choice did people who were visiting...
|
by: Brett |
last post by:
Why would you not want to use checked on any type of mathematical operation?
Or use unchecked for that matter?
Thanks,
Brett
|
by: bredal Jensen |
last post by:
Dear gurus,
I have a "farm " of radio buttons server control in a table. I need to
detect
when the user has selected any of them( before any postback).
i'm not quit sure how to do this.
Is there a way of making the readio button trigger a post back to the server
whenever it is selcted?
|
by: Jim Bancroft |
last post by:
Hi everyone,
I'm using a DataGrid with TemplateColumns. My DataGrid is located in a cell
of an asp:Table. I did this so it's positioned correctly onscreen.
One of the DataGrid's TemplateColumns is a checkbox. During the page's
postback I loop over the DataGrid and read the checkbox values. My problem
is, none of the checkboxes ever have their "Checked" attribute set-- it's as
though anything I mark is ignored.
| |
by: Samuel Chowdhuri |
last post by:
this peace of code is giving me trouble
DIM i as DataGridItem
for each i in myDataGrid
checkbox chkbox = Ctype(i.findcontrol("deletethis"),checkbox)
if(chkbox.checked) then
......
.....
|
by: painkiller |
last post by:
language: vb.net
environment: windows forms
.net : v1.1
i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from database. when a user clicks any of the above values and saves the form, the item's "value" is getting saved in database. and when a user logs back in, his/her previously checked value items should be shown as checked.
Everything is working fine...
|
by: AliRezaGoogle |
last post by:
Dear Members
Hi,
I have a question:
Why doesn't "checked" work for sub calls? For example consider the
following snippet of code:
checked
{
Overflower();
}
|
by: uicouic |
last post by:
Hi all. I need JavaScript to validate that atleast one checkbox has been checked in a form before the record(s) can be deleted.
- I have an <asp:button id="btnDelete"...> and the checkbox is created via grdData_ItemDataBound with id="chkRecordId":
Protected Sub grdData_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdData.ItemDataBound
If e.Item.ItemType <>...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |