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

Access rows of a created table


I have a javascript function that catches a click event of a row in a
table, but I am looking for a way to simulate a click in the first row
on page load.
function onRowClick(row)
{
//Do something

}
My table is actually a .Net Datagrid named dgrList, here is the grid
<asp:datagrid id="dgrList" runat="server" Width="448px"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="3" GridLines="Horizontal"
autogeneratecolumns="False">
Now when I try to run something like
onRowClick(document.frmRemoteScan.dgrList.rows(0)) ;
I get the message that dgrList is null or not an object, and when I
loop throught the elements in my form, dgrList is not one of them(yes
it is between the form tags).
My question, is there a way to reference the created table via
javascipt? Or does anyone have a way to simulate the row clcik via
javascript

Mar 20 '06 #1
4 1425
I figured this out, and wanted to help anyone that might stumble on
this post

try document.getElementById('dgrList').rows

Mar 20 '06 #2
sc**********@gmail.com wrote:
I have a javascript function that catches a click event of a row in a
table, but I am looking for a way to simulate a click in the first row
on page load.

function onRowClick(row)
{
//Do something
}

My table is actually a .Net Datagrid named dgrList, here is the grid
<asp:datagrid id="dgrList" runat="server" Width="448px"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="3" GridLines="Horizontal"
autogeneratecolumns="False">
This is not what the client gets, so not what the client-side script has to
operate on.
Now when I try to run something like
onRowClick(document.frmRemoteScan.dgrList.rows(0)) ;
I get the message that dgrList is null or not an object,
Then it is so.
and when I loop throught the elements in my form, dgrList is not one of
them(yes it is between the form tags).
Only form controls are part of the `elements' collection. A table is no
form control. And it should be `.rows[0]'.
My question, is there a way to reference the created table via javascipt?
There is. My first educated guess would be
document.getElementById("dgrList") -- with proper feature test --, but you
should really look at the generated source code, not the generating one.

<URL:http://jibbering.com/faq/>
Or does anyone have a way to simulate the row clcik via javascript


<URL:http://developer.mozilla.org/en/docs/DOM:document.createEvent>
PointedEars
Mar 20 '06 #3
sc**********@gmail.com said on 21/03/2006 8:10 AM AEST:
I figured this out, and wanted to help anyone that might stumble on
this post

try document.getElementById('dgrList').rows


Note Thomas' reply, some (most?) browsers don't provide a click method
for all elements even though they support the onclick attribute.

<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-2651361>

If rowRef is a reference to a row, then rowRef.click() may 'work' in
some browsers (e.g. IE), but not others (e.g. Firefox). You need to use
createEvent to attach the event so you can click on it.
<script type="text/javascript">

function clickOn(id)
{
var el;
if ( document.getElementById
&& (el = document.getElementById(id))){

// Create an event object
if ( document.createEvent ){
var eventObj = document.createEvent("MouseEvent");

// Initialise properties
eventObj.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);

// Run the event
if (el.dispatchEvent) el.dispatchEvent(eventObj);

} else if (el.click) {
el.click();
}
}
}

function sayHi(){alert('hi');}

</script>

<input type="button" value="Attach click"
onclick="clickOn('tr01');">

<table border="1">
<tr id="tr01" onclick="sayHi();">
<td>Click the button to fire the onclick event</td>
</tr>
</table>

--
Rob
Mar 20 '06 #4
RobG said on 21/03/2006 9:16 AM AEST:
sc**********@gmail.com said on 21/03/2006 8:10 AM AEST:
I figured this out, and wanted to help anyone that might stumble on
this post

try document.getElementById('dgrList').rows

Note Thomas' reply, some (most?) browsers don't provide a click method
for all elements even though they support the onclick attribute.

<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-2651361>

If rowRef is a reference to a row, then rowRef.click() may 'work' in
some browsers (e.g. IE), but not others (e.g. Firefox). You need to use
createEvent to attach the event so you can click on it.


That should be: dispatch the event to run the onclick handler.

[...]

--
Rob
Mar 21 '06 #5

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

Similar topics

1
by: annie | last post by:
Hi all, I have recently ported my Access 2000 app to SQL Server, keeping the Access client as the front end using linked tables. I am also using triggers on my SQL tables to trap orphan...
3
by: premmehrotra | last post by:
I am using Access 2000 and Oracle 9.2.0.x on a Windows 2000. I have setup Oracle 9.2 ODBC Driver (I have not yet figured how to set Microsoft's Oracle ODBC driver). I am exporting a table from...
0
by: Marc | last post by:
I have a Vb 6.0 project The VB 6.0 project with a just a click of the button...exports the calender rows from OUtlook to a MS Access file ( a DB and a table with the calender rows are created)...
5
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my...
10
by: Eric E | last post by:
Hi all, I am using an Access client linked to a PG 7.4 server via ODBC. I have a stored proc on the server that inserts rows into a table.particular table, accomplished via an INSERT within the...
8
by: Marcel Hug | last post by:
Hi all ! I have datas in a dataset. I would like to save them in a new table (just created). Do I have to run trought all recordsets with an Insert into statement ? (it takes very long) Thanks
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
4
by: RSH | last post by:
Hi, I have a situation where I have created a little application that makes an Access database from a SQL Database for reporting purposes. it does the job well, but it seems a bit slow. Is...
0
by: comp974 | last post by:
ok, here is the situation, I am trying to construct a table with several ASP.net 2.0 controls in it during execution time in an VB.net enviroment. For starters, I have a textbox and a linkbutton...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.