Re: onclick - reassign new function with parameters after displaye
- From: brian_harris <brianharris@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 28 Sep 2007 10:15:03 -0700
"Anthony Jones" wrote:
"brian_harris" <brianharris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in messageI will try to explan a little better, hopefuly with out making a book out of
news:C013C3CA-3B47-48F9-AB6C-DAAF32CCD895@xxxxxxxxxxxxxxxx
I have an HTML screen with several lines of data, each record has a buttonis
with an onclick event assigned. ( This is initially done throug XSL) Below
code snippet of that assignment. (this part of code works fine)select="hprdcode"/>',
<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
'<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 databaseand
may be different with each record line that was setup by XSL.was
When user modifies data in form they may be modifing some of the data that
in the orginal XSL asScan() parameters. I have modified the data that isto
displayed in the screen so user sees new values, but I have not been able
modify the onclick event to call asScan with new parameters. I have triedan
many things, It seems that I some how need to use the function() to create
anonymos function, but I have not gotten syntax correct yet. I get one oftwo
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.
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.
As described above the records are related. I believe I need these
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?
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 detailsI did try to find a way not to have to do this, but I could find noway of
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.
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.
Avoid using IDs on elements instead make function calls aware of the elementI am using IDs because I found no other way to access the orginal HTML and
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.
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.
You appear to be using non-standard XSL (<xsl:eval>) ditch this form of XSLI don't know why you say this is not standard. It is in documentation I
for standard XSL.
have come across for xsl. The only place I use it is to pass the unique
identifier of row to be able to create ID names in form. I don't rember what
I got before I put the eval in code, but it was not the number that the
variable represents.
Thanks in advance for any help you can give me to get on correct track.
.
- Follow-Ups:
- Re: onclick - reassign new function with parameters after displaye
- From: Anthony Jones
- Re: onclick - reassign new function with parameters after displaye
- From: Joe Fawcett
- Re: onclick - reassign new function with parameters after displaye
- References:
- Re: onclick - reassign new function with parameters after displayed
- From: Anthony Jones
- Re: onclick - reassign new function with parameters after displayed
- Prev by Date: Re: onclick - reassign new function with parameters after displayed
- Next by Date: Change current window property from resizable window to unresizable window
- Previous by thread: Re: onclick - reassign new function with parameters after displayed
- Next by thread: Re: onclick - reassign new function with parameters after displaye
- Index(es):
Loading