onload ... problem

M

Mel Smith

Hi:

Enviro: Running my own apache server, many years experience in database
design and business apps. -- but only five months learning web page design.
and I'm using my own C-based CGI app to handle all forms (including
building, and modifying and sending them out on the net.


Situation:
A 600 entry online phone book where I have about 6 entries displayed in
the view port with a slider on the right-hand side. I use the <table>,<tr>
and <td> elements for this, plus an "EDIT" button in the name/phone block
that I wish to be viewed.

Problem:
After loading this page, I want to display a specific row(s).

I tried using:
<body onload="window.document.getElementById('lot318').focus();" >

(and of course, put the id="lot318" in the <input >element

But the display just showed the beginning of the table.

Thanks for Any comments

-Mel Smith
 
M

Martin Honnen

Mel said:
Problem:
After loading this page, I want to display a specific row(s).

I tried using:
<body onload="window.document.getElementById('lot318').focus();" >

(and of course, put the id="lot318" in the <input >element

But the display just showed the beginning of the table.

Do you want to set focus to a control or do you want to scroll a certain
row into view? In the latter case you could do e.g.
var row =
document.getElementById('tableId').rows[rowIndex].scrollIntoView(true);

https://developer.mozilla.org/en/DOM/element.scrollIntoView
 
M

Mel Smith

Martin said:

Mel Smith said:
Martin Honnen said:
Do you want to set focus to a control or do you want to scroll a certain
row into view? In the latter case you could do e.g.
var row =
document.getElementById('tableId').rows[rowIndex].scrollIntoView(true);


Martin:

I shortened and changed your solution just a little bit to the following
(and it works perfectly ! )


<body
onload="document.getElementById('myEditButton').scrollIntoView();">

It works *great* !

Thanks you very much for this simple and elegant solution to my Problem.

-Mel Smith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top