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.

How do I reference the current element in DHTML?

7 posts in General Discussion Last posting was on 2010-01-18 16:55:16.0Z
Shao Chan Posted on 2010-01-12 16:04:12.0Z
Reply-To: "Shao Chan" <nospam@nospam.com>
From: "Shao Chan" <nospam@nospam.com>
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: How do I reference the current element in DHTML?
Lines: 43
Organization: Civica
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b4c9d7c@forums-1-dub>
Date: 12 Jan 2010 08:04:12 -0800
X-Trace: forums-1-dub 1263312252 10.22.241.152 (12 Jan 2010 08:04:12 -0800)
X-Original-Trace: 12 Jan 2010 08:04:12 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1467
Article PK: 17992

Hi all,

I have a screen where I create a list of tasks.

Code is something like:

var nodeTable = document.getElementById("jobtask_list");
var nodeText = document.createTextNode(contractItemDesc);
var nodeTR = null;
var nodeTD = null;
var nodeTR2 = null;
var nodeTD2 = null;
var nodeTD3 = null;
var nodeInput = document.createElement("input");
var nodeInputHidden = document.createElement("input");
var nodeCheckBox = document.createElement("input");

nodeCheckBox.id = taskId;
nodeCheckBox.setAttribute("type","checkbox");
nodeCheckBox.setAttribute("name","list");
nodeInput.id = "value" + taskId;
nodeInputHidden.id = "hiddenvalue" + taskId;
nodeInput.size = "2";
nodeInput.maxlength = "2";
nodeInput.onclick = getThisElementIdAndDoSomething;
nodeInput.onblur = hideKeyboard;

I want to be able to define a functioon called
getThisElementIdAndDoSomething and receive a parameter. However,
getThisElementIdAndDoSomething is an event handler.

I have 2 problems:
1) I cannot pass a parameter.
2) I don't know, when the event fires, how to retrieve the current element
id of the field I have clicked inside.

Can anyone point me to any documentation to achieve this or give an example?

Thanks.

Shao


Jeff Albion [Sybase iAnywhere] Posted on 2010-01-12 17:04:28.0Z
From: "Jeff Albion [Sybase iAnywhere]" <firstname.lastname@ianywhere.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0
MIME-Version: 1.0
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Re: How do I reference the current element in DHTML?
References: <4b4c9d7c@forums-1-dub>
In-Reply-To: <4b4c9d7c@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b4cab9c$1@forums-1-dub>
Date: 12 Jan 2010 09:04:28 -0800
X-Trace: forums-1-dub 1263315868 10.22.241.152 (12 Jan 2010 09:04:28 -0800)
X-Original-Trace: 12 Jan 2010 09:04:28 -0800, vip152.sybase.com
Lines: 57
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1468
Article PK: 17993

Hi Shao,

On 1/12/2010 11:04 AM, Shao Chan wrote:
> var nodeInput = document.createElement("input");
> var nodeInputHidden = document.createElement("input");
> var nodeCheckBox = document.createElement("input");
>
> nodeCheckBox.id = taskId;
> nodeCheckBox.setAttribute("type","checkbox");
> nodeCheckBox.setAttribute("name","list");
> nodeInput.id = "value" + taskId;
> nodeInputHidden.id = "hiddenvalue" + taskId;
> nodeInput.size = "2";
> nodeInput.maxlength = "2";
> nodeInput.onclick = getThisElementIdAndDoSomething;
> nodeInput.onblur = hideKeyboard;
>
> I want to be able to define a functioon called
> getThisElementIdAndDoSomething and receive a parameter. However,
> getThisElementIdAndDoSomething is an event handler.
>
> I have 2 problems:
> 1) I cannot pass a parameter.
> 2) I don't know, when the event fires, how to retrieve the current element
> id of the field I have clicked inside.

When the event fires, the 'this' object is always maintained in the
reference, if called by a registered event handler. For a really good
reference on this behaviour, see: http://www.quirksmode.org/js/this.html

(QM is one of my favourite JavaScript websites, ever. :)

---

So, the code would look something like:

============
nodeInput.onclick = getThisElementIdAndDoSomething;

function getThisElementIdAndDoSomething() {
var elementId;
elementId = this.id;
//... and then do something!
}
============

Cheers,

--
Jeff Albion, Sybase iAnywhere

iAnywhere Developer Community :
http://www.sybase.com/developer/library/sql-anywhere-techcorner
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
SQL Anywhere Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
Report a Bug/Open a Case : http://case-express.sybase.com/cx/


Shao Chan Posted on 2010-01-13 09:18:08.0Z
Reply-To: "Shao Chan" <nospam@nospam.com>
From: "Shao Chan" <nospam@nospam.com>
Newsgroups: ianywhere.public.mbusinessanywhere.general
References: <4b4c9d7c@forums-1-dub> <4b4cab9c$1@forums-1-dub>
Subject: Re: How do I reference the current element in DHTML?
Lines: 77
Organization: Civica
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b4d8fd0@forums-1-dub>
Date: 13 Jan 2010 01:18:08 -0800
X-Trace: forums-1-dub 1263374288 10.22.241.152 (13 Jan 2010 01:18:08 -0800)
X-Original-Trace: 13 Jan 2010 01:18:08 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1469
Article PK: 9442

Hi Jeff,

Thanks for that.

I was aware of this but I didn't know it had any scope outside of the
function, i.e. it wouldn't know anything about the current HTML element
calling it.

It works. Thanks.

Cheers,

Shao

"Jeff Albion [Sybase iAnywhere]" <firstname.lastname@ianywhere.com> wrote in
message news:4b4cab9c$1@forums-1-dub...
> Hi Shao,
>
> On 1/12/2010 11:04 AM, Shao Chan wrote:
>> var nodeInput = document.createElement("input");
>> var nodeInputHidden = document.createElement("input");
>> var nodeCheckBox = document.createElement("input");
>>
>> nodeCheckBox.id = taskId;
>> nodeCheckBox.setAttribute("type","checkbox");
>> nodeCheckBox.setAttribute("name","list");
>> nodeInput.id = "value" + taskId;
>> nodeInputHidden.id = "hiddenvalue" + taskId;
>> nodeInput.size = "2";
>> nodeInput.maxlength = "2";
>> nodeInput.onclick = getThisElementIdAndDoSomething;
>> nodeInput.onblur = hideKeyboard;
>>
>> I want to be able to define a functioon called
>> getThisElementIdAndDoSomething and receive a parameter. However,
>> getThisElementIdAndDoSomething is an event handler.
>>
>> I have 2 problems:
>> 1) I cannot pass a parameter.
>> 2) I don't know, when the event fires, how to retrieve the current
>> element
>> id of the field I have clicked inside.
>
> When the event fires, the 'this' object is always maintained in the
> reference, if called by a registered event handler. For a really good
> reference on this behaviour, see: http://www.quirksmode.org/js/this.html
>
> (QM is one of my favourite JavaScript websites, ever. :)
>
> ---
>
> So, the code would look something like:
>
> ============
> nodeInput.onclick = getThisElementIdAndDoSomething;
>
> function getThisElementIdAndDoSomething() {
> var elementId;
> elementId = this.id;
> //... and then do something!
> }
> ============
>
> Cheers,
>
> --
> Jeff Albion, Sybase iAnywhere
>
> iAnywhere Developer Community :
> http://www.sybase.com/developer/library/sql-anywhere-techcorner
> iAnywhere Documentation :
> http://www.ianywhere.com/developer/product_manuals
> SQL Anywhere Patches and EBFs :
> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
> Report a Bug/Open a Case : http://case-express.sybase.com/cx/


Shao Chan Posted on 2010-01-13 11:11:37.0Z
Reply-To: "Shao Chan" <nospam@nospam.com>
From: "Shao Chan" <nospam@nospam.com>
Newsgroups: ianywhere.public.mbusinessanywhere.general
References: <4b4c9d7c@forums-1-dub> <4b4cab9c$1@forums-1-dub> <4b4d8fd0@forums-1-dub>
Subject: .style.color (Re: How do I reference the current element in DHTML?)
Lines: 94
Organization: Civica
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b4daa69@forums-1-dub>
Date: 13 Jan 2010 03:11:37 -0800
X-Trace: forums-1-dub 1263381097 10.22.241.152 (13 Jan 2010 03:11:37 -0800)
X-Original-Trace: 13 Jan 2010 03:11:37 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1470
Article PK: 9441

Hi all,

I can't get

nodeInput.style.color = "#FF0000";
to work.

Is this supported or have I got my syntax wrong?

Cheers,

Shao

"Shao Chan" <nospam@nospam.com> wrote in message
news:4b4d8fd0@forums-1-dub...
> Hi Jeff,
>
> Thanks for that.
>
> I was aware of this but I didn't know it had any scope outside of the
> function, i.e. it wouldn't know anything about the current HTML element
> calling it.
>
> It works. Thanks.
>
> Cheers,
>
> Shao
>
> "Jeff Albion [Sybase iAnywhere]" <firstname.lastname@ianywhere.com> wrote
> in message news:4b4cab9c$1@forums-1-dub...
>> Hi Shao,
>>
>> On 1/12/2010 11:04 AM, Shao Chan wrote:
>>> var nodeInput = document.createElement("input");
>>> var nodeInputHidden = document.createElement("input");
>>> var nodeCheckBox = document.createElement("input");
>>>
>>> nodeCheckBox.id = taskId;
>>> nodeCheckBox.setAttribute("type","checkbox");
>>> nodeCheckBox.setAttribute("name","list");
>>> nodeInput.id = "value" + taskId;
>>> nodeInputHidden.id = "hiddenvalue" + taskId;
>>> nodeInput.size = "2";
>>> nodeInput.maxlength = "2";
>>> nodeInput.onclick = getThisElementIdAndDoSomething;
>>> nodeInput.onblur = hideKeyboard;
>>>
>>> I want to be able to define a functioon called
>>> getThisElementIdAndDoSomething and receive a parameter. However,
>>> getThisElementIdAndDoSomething is an event handler.
>>>
>>> I have 2 problems:
>>> 1) I cannot pass a parameter.
>>> 2) I don't know, when the event fires, how to retrieve the current
>>> element
>>> id of the field I have clicked inside.
>>
>> When the event fires, the 'this' object is always maintained in the
>> reference, if called by a registered event handler. For a really good
>> reference on this behaviour, see: http://www.quirksmode.org/js/this.html
>>
>> (QM is one of my favourite JavaScript websites, ever. :)
>>
>> ---
>>
>> So, the code would look something like:
>>
>> ============
>> nodeInput.onclick = getThisElementIdAndDoSomething;
>>
>> function getThisElementIdAndDoSomething() {
>> var elementId;
>> elementId = this.id;
>> //... and then do something!
>> }
>> ============
>>
>> Cheers,
>>
>> --
>> Jeff Albion, Sybase iAnywhere
>>
>> iAnywhere Developer Community :
>> http://www.sybase.com/developer/library/sql-anywhere-techcorner
>> iAnywhere Documentation :
>> http://www.ianywhere.com/developer/product_manuals
>> SQL Anywhere Patches and EBFs :
>> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
>> Report a Bug/Open a Case : http://case-express.sybase.com/cx/
>
>


Jeff Albion [Sybase iAnywhere] Posted on 2010-01-13 15:56:13.0Z
From: "Jeff Albion [Sybase iAnywhere]" <firstname.lastname@ianywhere.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0
MIME-Version: 1.0
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Re: .style.color (Re: How do I reference the current element in DHTML?)
References: <4b4c9d7c@forums-1-dub> <4b4cab9c$1@forums-1-dub> <4b4d8fd0@forums-1-dub> <4b4daa69@forums-1-dub>
In-Reply-To: <4b4daa69@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b4ded1d$1@forums-1-dub>
Date: 13 Jan 2010 07:56:13 -0800
X-Trace: forums-1-dub 1263398173 10.22.241.152 (13 Jan 2010 07:56:13 -0800)
X-Original-Trace: 13 Jan 2010 07:56:13 -0800, vip152.sybase.com
Lines: 61
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1473
Article PK: 9444

Hi Shao,

Is this code inside the event handler? If so, I'd expect the code to
look like:

this.style.color = "#FF0000";

---

Also, if this is on WinCE, note that for updates to the DOM (e.g. colour
changes) via an onclick event are only handled after the Windows CE
'click-and-hold' functionality has been processed (after ~500ms, IIRC).

So, if the function does something like:

======
function getThisElementIdAndDoSomething() {
var elementId;
elementId = this.id;

// Change colour of <input> element when clicked in order to
// conform to Section 508 guidelines for accessibility

this.style.color = "#FF0000";

// Go to the next screen

document.location.href = 'nextpage.html';
}
======

The colour change will not be rendered before the page location switches
in the browser, due to the click-and-hold handler consuming 500 ms.

To change this behaviour to render the immediate change in the DOM, you
may have to disable the WinCE click-and-hold functionality handler. In
the <body> tag, try adding an onLoad event to remove the handler:

<body
onLoad="avantgo.preferences.setBoolValueForKey('DisableRightClickPopup',
true);">

Regards,

On 1/13/2010 6:11 AM, Shao Chan wrote:
> I can't get
>
> nodeInput.style.color = "#FF0000";
> to work.
>
> Is this supported or have I got my syntax wrong?
>

--
Jeff Albion, Sybase iAnywhere

iAnywhere Developer Community :
http://www.sybase.com/developer/library/sql-anywhere-techcorner
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
SQL Anywhere Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
Report a Bug/Open a Case : http://case-express.sybase.com/cx/


Shao Chan Posted on 2010-01-14 09:48:58.0Z
From: "Shao Chan" <nospam@nospam.com>
Newsgroups: ianywhere.public.mbusinessanywhere.general
References: <4b4c9d7c@forums-1-dub> <4b4cab9c$1@forums-1-dub> <4b4d8fd0@forums-1-dub> <4b4daa69@forums-1-dub> <4b4ded1d$1@forums-1-dub>
Subject: Re: .style.color (Re: How do I reference the current element in DHTML?)
Lines: 77
Organization: Civica
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b4ee88a$1@forums-1-dub>
Date: 14 Jan 2010 01:48:58 -0800
X-Trace: forums-1-dub 1263462538 10.22.241.152 (14 Jan 2010 01:48:58 -0800)
X-Original-Trace: 14 Jan 2010 01:48:58 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1474
Article PK: 9443

Hi Jeff,

Yes, that's how it looks.

I even put it in my initialisation code which does not rely on the event
handler and it doesn't change the colour.

Cheers,

Shao

"Jeff Albion [Sybase iAnywhere]" <firstname.lastname@ianywhere.com> wrote in
message news:4b4ded1d$1@forums-1-dub...
> Hi Shao,
>
> Is this code inside the event handler? If so, I'd expect the code to look
> like:
>
> this.style.color = "#FF0000";
>
> ---
>
> Also, if this is on WinCE, note that for updates to the DOM (e.g. colour
> changes) via an onclick event are only handled after the Windows CE
> 'click-and-hold' functionality has been processed (after ~500ms, IIRC).
>
> So, if the function does something like:
>
> ======
> function getThisElementIdAndDoSomething() {
> var elementId;
> elementId = this.id;
>
> // Change colour of <input> element when clicked in order to
> // conform to Section 508 guidelines for accessibility
>
> this.style.color = "#FF0000";
>
> // Go to the next screen
>
> document.location.href = 'nextpage.html';
> }
> ======
>
> The colour change will not be rendered before the page location switches
> in the browser, due to the click-and-hold handler consuming 500 ms.
>
> To change this behaviour to render the immediate change in the DOM, you
> may have to disable the WinCE click-and-hold functionality handler. In the
> <body> tag, try adding an onLoad event to remove the handler:
>
> <body
> onLoad="avantgo.preferences.setBoolValueForKey('DisableRightClickPopup',
> true);">
>
> Regards,
>
> On 1/13/2010 6:11 AM, Shao Chan wrote:
>> I can't get
>>
>> nodeInput.style.color = "#FF0000";
>> to work.
>>
>> Is this supported or have I got my syntax wrong?
>>
> --
> Jeff Albion, Sybase iAnywhere
>
> iAnywhere Developer Community :
> http://www.sybase.com/developer/library/sql-anywhere-techcorner
> iAnywhere Documentation :
> http://www.ianywhere.com/developer/product_manuals
> SQL Anywhere Patches and EBFs :
> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
> Report a Bug/Open a Case : http://case-express.sybase.com/cx/


Jeff Albion [Sybase iAnywhere] Posted on 2010-01-18 16:55:16.0Z
From: "Jeff Albion [Sybase iAnywhere]" <firstname.lastname@ianywhere.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0
MIME-Version: 1.0
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Re: .style.color (Re: How do I reference the current element in DHTML?)
References: <4b4c9d7c@forums-1-dub> <4b4cab9c$1@forums-1-dub> <4b4d8fd0@forums-1-dub> <4b4daa69@forums-1-dub> <4b4ded1d$1@forums-1-dub> <4b4ee88a$1@forums-1-dub>
In-Reply-To: <4b4ee88a$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b549274$1@forums-1-dub>
Date: 18 Jan 2010 08:55:16 -0800
X-Trace: forums-1-dub 1263833716 10.22.241.152 (18 Jan 2010 08:55:16 -0800)
X-Original-Trace: 18 Jan 2010 08:55:16 -0800, vip152.sybase.com
Lines: 23
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:1477
Article PK: 17996

Hi Shao,

Can you post a complete code sample to show this example? Which platform
/ version of the M-Business client are you using to test this with?

Thanks!

On 1/14/2010 4:48 AM, Shao Chan wrote:
> Yes, that's how it looks.
>
> I even put it in my initialisation code which does not rely on the event
> handler and it doesn't change the colour.
>

--
Jeff Albion, Sybase iAnywhere

iAnywhere Developer Community :
http://www.sybase.com/developer/library/sql-anywhere-techcorner
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
SQL Anywhere Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
Report a Bug/Open a Case : http://case-express.sybase.com/cx/