Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 23rd, 2006, 03:22 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default help in xsl getting row number

Dear Friends,

I am genarating n number of record dynamically in xml

format . i am dispaly it in table format with xsl. Each record

contains a run button . in that xsl i am using the same code for each

record .




now the problem is , when click the particular button (say


button in row 2 ) it should return the row number( ie 2).

i am using the same code for button generation , so it will call

the same function on a click of all Button .i can't get specific

row number ?

please give me some idea.
  #2 (permalink)  
Old January 23rd, 2006, 05:16 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There are various ways you can generate a sequential number in XSLT, for example the position() function, or the xsl:number instruction.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old January 23rd, 2006, 05:59 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how to identify which button is clicked ,by the

same function?
  #4 (permalink)  
Old January 23rd, 2006, 07:03 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Remember that you use XSLT to generate the HTML source code, not to respond to user events in the browser. Identifying the button that's been clicked is something that happens long after the XSLT has finished executing. Think about how you would write an HTML page with multiple buttons "by hand", (i.e. with each button having a unique label), and then think about how to write the XSLT to generate that HTML.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #5 (permalink)  
Old January 23rd, 2006, 08:18 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thankz for ur reply. how can we get the source

of click ( name of the button ) in OnClick Event?


i am calling same function for every button's

onClick Event ?
  #6 (permalink)  
Old January 23rd, 2006, 09:00 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Call the function with a parameter that identifies the button.

In your XSLT, generate the code for the function call to include a value for this parameter, eg..

<button onClick="process-button({position()})">



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #7 (permalink)  
Old January 23rd, 2006, 10:00 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

very very thankz for reply sir......it really

works well.


Similar Threads
Thread Thread Starter Forum Replies Last Post
To retrieve a row by giving row number prad_a MySQL 1 March 22nd, 2007 11:20 PM
Serial Number with each table row ketannsharma Access 3 March 16th, 2007 06:44 AM
use of xsl:number alleycat XSLT 4 February 27th, 2006 04:21 AM
Select row number N 1kHz SQL Language 4 December 27th, 2004 06:22 AM
xsl:number N.Todd XSLT 3 October 7th, 2003 08:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.