473,320 Members | 1,724 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,320 software developers and data experts.

Clicking anywhere on report row

I have a HTML table with onmouseover/onmouseout event handlers to
change the bgcolor of the report row as the mouse moves over it.

The row also has a radio button on it.

Is there a way to click anywhere on the row and have the radiobutton be
clicked?

By attaching a onClick on the TR and having it bubble up (down?) to the
radio element or something?

Thanks

Sep 23 '05 #1
3 1279
OK got it working

Added a onClick event handler to the TR tag

<tr onClick="ClickRadio(this);">

Do I need to worry about the onClick event bubbling up to higher
elements? Do I need to do the cancelPropagation and stuff?

<script type="text/javascript">
function ClickRadio(p_tr)
{
var l_element;
for( var ii = 0; ii < p_tr.childNodes.length; ii++ ) {
if (p_tr.childNodes[ii].tagName=="TD") {
for (var j=0; j< p_tr.childNodes[ii].childNodes.length;j++)
{
l_element=p_tr.childNodes[ii].childNodes[j];
if (l_element.tagName=='INPUT' &&
l_element.type=="radio") {
l_element.checked=true;
}
}
}
}
}
</script>

Works like a charm.

Hope this helps someone.

Sep 23 '05 #2
us****@vikas.mailshell.com wrote:
OK got it working

Added a onClick event handler to the TR tag

<tr onClick="ClickRadio(this);">

Do I need to worry about the onClick event bubbling up to higher
elements? Do I need to do the cancelPropagation and stuff?
Only if you want to prevent a click on your row from firing some other
onclick higher up the DOM.

<script type="text/javascript">
function ClickRadio(p_tr)
{
var l_element;
for( var ii = 0; ii < p_tr.childNodes.length; ii++ ) {
if (p_tr.childNodes[ii].tagName=="TD") {
for (var j=0; j< p_tr.childNodes[ii].childNodes.length;j++)
{
l_element=p_tr.childNodes[ii].childNodes[j];
if (l_element.tagName=='INPUT' &&
l_element.type=="radio") {
l_element.checked=true;
}
If you want to just check the radio button in the row, and presuming
p_tr is a reference to a row element, try:

var inputs = p_tr.getElementsByTagName('input');
var el, i = inputs.length;
while (i--){
el = inputs[i]
if ( el.type = 'radio' ){
el.checked = true;
}
}

}
}
}
}
</script>

Works like a charm.

Hope this helps someone.

--
Rob
Sep 24 '05 #3
RobG wrote:
[...]
var inputs = p_tr.getElementsByTagName('input');
var el, i = inputs.length;
while (i--){
el = inputs[i]
if ( el.type = 'radio' ){
That should of course be:

if ( el.type == 'radio' ){
el.checked = true;
}
}

[...]
--
Rob
Sep 24 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tony Williams | last post by:
I have a table "tblmaintabs" that stores data that is collected from various companies on a quarterly basis in March, June, September and December each year (these dates are stored in a Date/time...
2
by: George M. | last post by:
I'm working with the treeview control on an ASP.NET page (written in C#), and I have one built the looks something like: Root |_Category1 |_Site1 |_Report1 |_Report2 |_Site2 |_Report3...
0
by: Steven W | last post by:
I'm trying to setup a datagrid in a custom control where I can select the row with the Select column hidden and have it call the "SelectIndexChanged" event. In the "SelectIndexChanged" I just want...
1
by: .NETn00b | last post by:
Is this possible? I need to create a multi-select DataGrid, and I cannot use CheckBoxes. I want the selected rows to appear highlighted. One possible work-around that occurred to me was to...
0
by: misiek | last post by:
Hi all. In asp.net 1.1 I followed instructions from "Top Questions about the DataGrid Web Server Control" article to select some row in DataGrid by clicking anywhere in that row. However in...
1
by: mike11d11 | last post by:
For some reason I'm getting no data populating in my crystal report. I built my crystal report off my dataset in my project, and I fill the dataset when opening the main form, and count the...
33
by: STILL LEARNING | last post by:
I'm not sure if this can even be done, but what prompts the question is my desire to be able to create an "Uber Link" script/code of some sort, such that even if the html page contains nothing but...
1
by: Bobby | last post by:
Sorry if this is a dumb question. I'm using Access 2007. I have a report which I am opening via VBA, with the following command: stDocName = "Quotation Report" DoCmd.OpenReport stDocName,...
7
by: ismailc | last post by:
Good day; When I click anywhere on the form a particular button remains selected & focused. Even while i'm busy typing in another textbox the button looks as if it's being selected with a dark...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.