Re: onclick - reassign new function with parameters after displaye
- From: brian_harris <brianharris@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 4 Oct 2007 13:05:06 -0700
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
button
"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
Belowwith an onclick event assigned. ( This is initially done throug XSL)
javascript:top.contentFrame.asScan(<xsl:eval>lineNumber</xsl:eval>,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">
database'<xsl:value-of select="empcode"/>','<xsl:value-ofselect="hprdcode"/>',
'<xsl:value-of select="empupdate"/>',select="empfnme"/>',
'<xsl:value-of select="strtdate"/>', '<xsl:value-of
'<xsl:value-of select="emplnme"/>','<xsl:value-ofselect="prodcode"/>',
'<xsl:value-of select="skilltpe"/>', '<xsl:value-offrom
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
database, the parameters are needed to get correct records from
thatand
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
iswas
in the orginal XSL asScan() parameters. I have modified the data that
abledisplayed in the screen so user sees new values, but I have not been
triedto
modify the onclick event to call asScan with new parameters. I have
createmany things, It seems that I some how need to use the function() to
ofan
anonymos function, but I have not gotten syntax correct yet. I get one
totwo
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 bewhat I want to do). I believe that all the data for parameters have
",'"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')
frame+
"','" + 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
itsstructure 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
ofdifficult to know where to start.I will try to explan a little better, hopefuly with out making a book out
it.snippet
To start with the XSL portion of the code works fine, that is first
of code.when
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
I try to redefine parameters in onclick event of the orginal button.type
The orginal XSL is creating a record that shows data from two different
of records. 1 record represent a individual employee schedule recorddefined
prior to the actual work day. the second record represents what theemployee
actually worked. These two records are matched by a complicated oracleone
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
or the other record to make them match.information
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
the form needs to do its job. Some of the records are used to populatemake
dropdown boxes with legal values. Then because we want to automatically
modified record to be correct as we believe it should be it uses the otherit
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
if want to. When user hits submit button it changes the data in oraclethis
database and the data being displayed inthe orginally displayed HTML
document. (all of the above works fine) So as stated in orginal question
is where I am having a problem. because in that orginal HTML document Ihave
those parameters whose data has now changed hard coded to old values and Iam
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.
parameters to
Let's start with your assertion that you need that pelthora of
Theselect the correct records from the Database. Clearly this is problem.
and'records' are related in someway surely, you're not editing on one formAs described above the records are related. I believe I need these
various un-connected records?
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
calls function it takes those variables and makes them global so that theother
HTML form which will then be called can access them, again I know of no
way for this seperate HTML file to get the data it needs.details
The following tips are a few other general things I've spotted but
arecan be filled in once we get a better understanding of the problem you
XSLtring to solve.
Don't have the XSL build long complex function calls. Instead have the
meansadd the parameters as expando attributes in the generated HTML (if those
values aren't already present in the HTML output). Typically this
inadding 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
the current row.quick
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
description of what HTML data looks likeabove
<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
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.
elementAvoid using IDs on elements instead make function calls aware of the
of athat is calling it. The best way to do this is to use the .call method
thefunction like this: - onclick="cmdMyButton_onclick.call(this)". Now
cancalled function sees the element as the 'this' context and from there
Inavigate up to the containing TR from which is can gather data from theI am using IDs because I found no other way to access the orginal HTML and
contents of TDs and expandos.
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
expand on using IDs I could possibly get most of data needed to run formmy
using same method I use to change data. But that still will not resolve
original problem, because to do this I would still need to pass the uniqueget
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
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"this".
button. So basically I don't now how to access the data from using
I presume I still would need to use ID's since some of data is in previousto
rows, and I would not know how many rows prior I would have to go to get
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.
XSL
You appear to be using non-standard XSL (<xsl:eval>) ditch this form of
for standard XSL.
- Follow-Ups:
- Re: onclick - reassign new function with parameters after displaye
- From: Joe Fawcett
- Re: onclick - reassign new function with parameters after displaye
- Prev by Date: restucture frame structure using js
- Next by Date: Re: onclick - reassign new function with parameters after displaye
- Previous by thread: restucture frame structure using js
- Next by thread: Re: onclick - reassign new function with parameters after displaye
- Index(es):