Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Dynamically Creating Anchors

3 posts in General Discussion Last posting was on 2004-04-05 15:18:34.0Z
Matthew Mamet Posted on 2004-04-02 12:53:46.0Z
Sender: 2768.406d5f46.1804289383@sybase.com
From: Matthew Mamet
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Dynamically Creating Anchors
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <406d6256.2786.846930886@sybase.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="-=_forums-2-dub406d6256"
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 2 Apr 2004 04:53:42 -0800, 10.22.241.42
Lines: 2619
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 2 Apr 2004 04:53:44 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 2 Apr 2004 04:53:46 -0800
X-Trace: forums-1-dub 1080910426 10.22.108.75 (2 Apr 2004 04:53:46 -0800)
X-Original-Trace: 2 Apr 2004 04:53:46 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:24
Article PK: 8692

Attached is a mock up of an HTML page I'm trying to create
for the Pocket PC. I'm using M-Biz Application Edition 5.2.

This page will draw data from 2 tables "Activity" and
"CallNotes"
If there is a record on a specific date for either Activity
or CallNotes, I want to list that date as a row in a table,
along with a link to an Edit Detail page for either Activity
or CallNotes.

I'm having trouble understanding how I can dynamically
create the anchor elements to do this.
For example, When I know I have a valid date for the
activity table, here's the code I have so far:

var anchor = document.createElement("a");
anchor.id = rs.activityid + "_activityanchor";
anchor.onclick = switchToDetail(rs.activityid);
anchor.appendChild(document.createTextNode(rs.activitydate))
;
cell.appendChild(anchor);

It seems the problem is the way I'm setting the onclick
property of my anchor element. On other pages, I have a
javascript function called switchToDetail that takes no
parameters. It works fine. On this page, I'm added a
parameter to the javascript function switchToDetail and it
doesn't seem to work.

I'm still very new to developing web pages using the DOM +
AvantGo so any help is appreciated. Both in answering the
specific question as well as different ways of accomplishing
the same task.


Chris Grim Posted on 2004-04-02 17:37:13.0Z
Sender: 2ba3.406da433.1804289383@sybase.com
From: Chris Grim
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Re: Dynamically Creating Anchors
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <406da4c5.2bb0.846930886@sybase.com>
References: <406d6256.2786.846930886@sybase.com>
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 2 Apr 2004 09:37:10 -0800, 10.22.241.42
Lines: 15
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 2 Apr 2004 09:37:10 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 2 Apr 2004 09:37:13 -0800
X-Trace: forums-1-dub 1080927433 10.22.108.75 (2 Apr 2004 09:37:13 -0800)
X-Original-Trace: 2 Apr 2004 09:37:13 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:27
Article PK: 17534

The problem is that you are actually calling the function
switchToDetail with this syntax. You need to use inline
function notation like this:

anchor.onclick = function() { switchToDetail(rs.activityid);
}

> var anchor = document.createElement("a");
> anchor.id = rs.activityid + "_activityanchor";
> anchor.onclick = switchToDetail(rs.activityid);
>
> anchor.appendChild(document.createTextNode(rs.activitydate
> )) ;
> cell.appendChild(anchor);
>


Matthew Mamet Posted on 2004-04-05 15:18:34.0Z
Sender: 593d.40716a20.1804289383@sybase.com
From: Matthew Mamet
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Re: Dynamically Creating Anchors
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <40716ab7.5941.846930886@sybase.com>
References: <406d6256.2786.846930886@sybase.com><406da4c5.2bb0.846930886@sybase.com>
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 5 Apr 2004 07:18:31 -0800, 10.22.241.42
Lines: 31
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 5 Apr 2004 07:18:33 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 5 Apr 2004 07:18:34 -0800
X-Trace: forums-1-dub 1081174714 10.22.108.75 (5 Apr 2004 07:18:34 -0800)
X-Original-Trace: 5 Apr 2004 07:18:34 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:31
Article PK: 8694

Excellent. The only thing I had to change was the parameter
of the function. I used the keyword 'this'.

I'm not sure, but I think this is because the browser is
trying to resolve the value of rs.activityid at the moment
of the onclick event, not during the loop.

In case someone in the future reads this and needs more
info, I found some additonal help at:
http://www.evolt.org/article/Javascript_navigation_cleaner_not_meaner/17/60273/


Thanks again for your help.

> The problem is that you are actually calling the function
> switchToDetail with this syntax. You need to use inline
> function notation like this:
>
> anchor.onclick = function() {
> switchToDetail(rs.activityid); }
>
> > var anchor = document.createElement("a");
> > anchor.id = rs.activityid + "_activityanchor";
> > anchor.onclick = switchToDetail(rs.activityid);
> >
> >
> >
> anchor.appendChild(document.createTextNode(rs.activitydate
> > )) ; cell.appendChild(anchor);
> >