Re: onclick - reassign new function with parameters after displaye



From my other research I had already thought that it was creating a string,
but I could never find correct way so that it was not a string. One way I
did find caused function to execute immediatly, not when onclick was hit.
But this whole issue is kind of moot, because while I am still passing
parameters, I am no longer passing parameters that are going to change in
code.

As far as XML data, it is not on the client side, and my limted
understanding of data island implies that is not appropriate in this case
since it seems like it would be duplicating data on client side. (The XML
data and the HTML data which is displaying all of that info in a specific
format and providing user interfaces to edit data. Also if I am not passing
as global parameter the info I need to get correct record from HTML, I also
won't have information I need to get it from data island

But I have a question relating from what you said earlier about xsl:eval. I
tried to get rid of it but could not figure how to get the functionality I
needed into XSL proscessing. It would just put the string lineNumber not the
value from javascript variable, I tried to use xsl:value-of but could not get
that to work, I also looked at xsl:variable, but that did not seem
appropriate. this variable is getting incremented while processing xsl, it
is incremented by one for each new record. I then use the # to create an id
at XSL level and also use it to get the HTML record I am currently processing
from DOM to get other data. Could you tell me

"Anthony Jones" wrote:

"brian_harris" <brianharris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:29FD00F0-58C5-4605-B1BA-0300EB81746F@xxxxxxxxxxxxxxxx


"Anthony Jones" wrote:

"brian_harris" <brianharris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C013C3CA-3B47-48F9-AB6C-DAAF32CCD895@xxxxxxxxxxxxxxxx
I have an HTML screen with several lines of data, each record has a
button
with an onclick event assigned. ( This is initially done throug XSL)
Below
is
code snippet of that assignment. (this part of code works fine)
<td CLASS="scanlen" ROWSPAN="2">
<button CLASS="tworow">
<xsl:attribute name="id">
<xsl:eval>lineNumber</xsl:eval>_asScan</xsl:attribute>
<xsl:attribute name="onclick">

javascript:top.contentFrame.asScan(<xsl:eval>lineNumber</xsl:eval>,
'<xsl:value-of select="empcode"/>','<xsl:value-of
select="hprdcode"/>',
'<xsl:value-of select="empupdate"/>',
'<xsl:value-of select="strtdate"/>', '<xsl:value-of
select="empfnme"/>',
'<xsl:value-of select="emplnme"/>','<xsl:value-of
select="prodcode"/>',
'<xsl:value-of select="skilltpe"/>', '<xsl:value-of
select="startscan"/>',
'<xsl:value-of select="endscan"/>', '<xsl:value-of
select="discrepancytype"/>');
</xsl:attribute>
As<br/>Scan
</button>
</td>

The asScan function calls an input form where it displays various data
from
database, the parameters are needed to get correct records from
database
and
may be different with each record line that was setup by XSL.
When user modifies data in form they may be modifing some of the data
that
was
in the orginal XSL asScan() parameters. I have modified the data that
is
displayed in the screen so user sees new values, but I have not been
able
to
modify the onclick event to call asScan with new parameters. I have
tried
many things, It seems that I some how need to use the function() to
create
an
anonymos function, but I have not gotten syntax correct yet. I get one
of
two
results
a) nothing happens when user press onclick button after reassignment
b) it executes the asScan button at time of assignment and fails on
setting onclick

Below is a 1 example of what I have tried. ( I think this is closeset
to
what I want to do). I believe that all the data for parameters have
to be
evaluated prior to assigning asScan to onclik event.

window.opener.document.all.item(window.opener.recordnum
+ '_asScan').onclick=function() {
"window.opener.top.contentFrame.asScan (" + window.opener.recordnum +
",'"
+
window.opener.recempcode + "','" + window.opener.hprdcode + "','"
+



schdDataSource.firstChild.nextSibling.firstChild.getAttribute('lastupdate')
+
"','" + data.startdate.value + ' ' + data.strtdateadjust.value +
"','" +
window.opener.empfnme + "','" + window.opener.emplnme + "','" +
window.opener.scanunit +
"','" + skilltpe + "','" + window.opener.startscan + "','" +
window.opener.endscan +
"','" + window.opener.discreptyp + "')"}


This all a little difficult to follow since you haven't described the
frame
structure or why the asScan function is looking to its opener to fetch
values. In fact there are clearly so many things going wrong with this
its
difficult to know where to start.
I will try to explan a little better, hopefuly with out making a book out
of
it.
To start with the XSL portion of the code works fine, that is first
snippet
of code.
It creates an HTML document which looks and acts correctly. Including the
button that was orginally created.
The second snippet of code is from code that is a popup form that is
activated by the previously defined button. The form works fine, except
when
I try to redefine parameters in onclick event of the orginal button.

The orginal XSL is creating a record that shows data from two different
type
of records. 1 record represent a individual employee schedule record
defined
prior to the actual work day. the second record represents what the
employee
actually worked. These two records are matched by a complicated oracle
trigger/procedure.
All records Being displayed are discrepancies in that for any one of
multiple reasons they do not match the other record, and user has to fix
one
or the other record to make them match.

The basic design of code is this
1) XSL creates an HTML document that for each combination of records
displays the data and provides various buttons to edit either one of the
records.

2) When button is pressed and javascript function called with those
parameters, it stores those parameters as global variables, which will be
referenced by the form code. This function then calls the .html file that
creates and manages the form.
This form is created in a popup window.

3) The form reads in those global variables. It uses some of them to get
the appropriate records from the oracle database, which has other
information
the form needs to do its job. Some of the records are used to populate
dropdown boxes with legal values. Then because we want to automatically
make
modified record to be correct as we believe it should be it uses the other
parameters to change what is being displayed in some of the form records.
Ideally then user just needs to review data and approve it, or can change
it
if want to. When user hits submit button it changes the data in oracle
database and the data being displayed inthe orginally displayed HTML
document. (all of the above works fine) So as stated in orginal question
this
is where I am having a problem. because in that orginal HTML document I
have
those parameters whose data has now changed hard coded to old values and I
am
trying to change them from with in the form at time submit button is being
processed.


I'm not going to pretend that I follow you completely but I don't think I
need to. Your are right you've got the syntaxt of the function in the
second clip of code wrong. You create a function that simply builds a
string:-

window.opener.document.all.item(window.opener.recordnum
+ '_asScan').onclick=function() {
"window.opener.top.contentFrame.asScan (" +
window.opener.recordnum + ",'" +
window.opener.recempcode + "','" +
window.opener.hprdcode + "','" +

schdDataSource.firstChild.nextSibling.firstChild.getAttribute('lastupdate')
+ "','" +
data.startdate.value + ' ' + data.strtdateadjust.value + "','" +
window.opener.empfnme + "','" +
window.opener.emplnme + "','" +
window.opener.scanunit + "','" +
skilltpe + "','" +
window.opener.startscan + "','" +
window.opener.endscan + "','" +
window.opener.discreptyp + "')"
}


Note this is perfecly legal code but all it does is build a string that I
suspect you actually want to execute or be the code body of the funtion.

However whilst this is probably the answer you were looking for you really
need to understand that it isn't a good approach. Passing this many
parameters around and using all that concatenation is bound to lead to
problems. Using global variables in the way you've described is also asking
for trouble.

If you have the XML clientside then all you need is a way to uniquely ID the
XML Node that forms the context of your little XSL. Store the ID of the
node on the button instead of all those parameters. When the function runs
it can retrieve the values it needs from the XML. When your code is making
changes instead of modifying global variables modify the XML directly. Now
when the code runs again it will retrieve these new values from the XML.

IOW instead of the data state being splattered all over the place in your
code and in global variables it exists only one place, the XML.

If you don't have the XML clientside then add it in an XML Data island.


Let's start with your assertion that you need that pelthora of
parameters to
select the correct records from the Database. Clearly this is problem.
The
'records' are related in someway surely, you're not editing on one form
various un-connected records?

As described above the records are related. I believe I need these
parameters because I know of no other way to pass them into the various
places I need them. I can't make them global variables at time XSL is
creating HTML, since there are many records. So once user presses button
and
calls function it takes those variables and makes them global so that the
HTML form which will then be called can access them, again I know of no
other
way for this seperate HTML file to get the data it needs.
The following tips are a few other general things I've spotted but
details
can be filled in once we get a better understanding of the problem you
are
tring to solve.

Don't have the XSL build long complex function calls. Instead have the
XSL
add the parameters as expando attributes in the generated HTML (if those
values aren't already present in the HTML output). Typically this
means
adding expandos to TR elements.

I did try to find a way not to have to do this, but I could find noway of
passing correct data when hit the button. Most but not all of the data is
in
the current row.
The employee code and name are in a parent row, and the type of records
working with are in a parent row to the employee data row. Below is a
quick
description of what HTML data looks like
<tr> data that represents a block of certain type of records </tr>
<tr> data that represents one employee record of above type </tr>
<tr> data that represents 1 individual record combination for
above
employee and type </tr>
At each level their can be multiple records when button is pressed in most
inner level it needs some of the data from each outer level to get correct
data. All data is in TD fields within the appropriate row.


Ok I see. Keeping the XML DOM around should enable you to find all the
appropriate data.


Avoid using IDs on elements instead make function calls aware of the
element
that is calling it. The best way to do this is to use the .call method
of a
function like this: - onclick="cmdMyButton_onclick.call(this)". Now
the
called function sees the element as the 'this' context and from there
can
navigate up to the containing TR from which is can gather data from the
contents of TDs and expandos.

I am using IDs because I found no other way to access the orginal HTML and
change the data being displayed by record. I didn't add the ID's to my
program until I got to point where I needed to update orginal HTML. So if
I
expand on using IDs I could possibly get most of data needed to run form
using same method I use to change data. But that still will not resolve
my
original problem, because to do this I would still need to pass the unique
identifier for row being processed to determine the ID of row I want data
from. I am also wondering about performance of doing all of that initial
lookups before I open the form

Before you mentioned I had never heard of the call() method, and after
looking up info in this I am still not sure how I can use this. Because
"this" seems to be representing the button. But I could find no way to
get
back to the other data in orginal HTML. "this" had no previousSibling,
and
in actual html there are other <td> fields in that record prior to the
button. So basically I don't now how to access the data from using
"this".
I presume I still would need to use ID's since some of data is in previous
rows, and I would not know how many rows prior I would have to go to get
to
correct data.

The button is the first element in the TD so it doesn't have a previous
sibling. However it does have a parentNode which is the TD which in turn
has siblings and has the TR as a parentNode.


You appear to be using non-standard XSL (<xsl:eval>) ditch this form of
XSL
for standard XSL.

.