![]() |
|
|
|||||||
| embarcadero.public.delphiphp.vclforphp.components.using This group is for all discussion about the use of VCL for PHP components. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
| Sponsored Links |
|
|
|
||||
|
I haven't messed with it much but these snippets will get the caption of a button or label in the dbrepeater.
Quote:
|
|
|||
|
It would be nice to be able to use something like the Tag property of the label component to store the record id of each record in the dbrepeater. That way the caption can display something appropriate (in my case a person's name) rather than just an id number. The problem is, I can't figure out how to access the label's tag from the client side.
I suppose I could make the label's caption something like "Bloggs, Fred [32441]" and use javascript to parse the string for the number in brackets, but it's easy enough to confuse my users without displaying strange numbers in front of them. Does anyone know how to access the tag property from javascript?
__________________
If it was too easy it would be no fun |
|
||||
|
The tag property is php only. It doesn't transfer to the javascript side at all.
There are multiple ways of doing something like that though. Examples: You can create a js object (key:value pairs) that stores your needed info. You can use hiddenFields that have the same naming conventions so you can access them. If you are using true js objects (like textfield or bitbutton) you can create a tag on the fly after it has been created. echo "textfield1.mynewproperty=32441;"; |
|
|||
|
Hi 405hp, and thanks for your post. Yes, I'm using hidden fields for other areas where I want to transfer data between the client and server side, but the problem here is that the label is in a dbrepeater. As far as I understand it, that means it's not possible to access the label directly. Until I saw your post earlier in this thread, I didn't even know you could use something like
Code:
var target = event.target || event.srcElement; The problem with key, value pairs is that I need the caption to display the value, which in the case of names is not guaranteed to be unique. If I display the key, then I'll just confuse my users, although it would function perfectly. Do you know if there's a way to add a property to a label inside a dbrepeater in php that's available to javascript when it gets to the client side?
__________________
If it was too easy it would be no fun |
|
||||
|
Quote:
key=jsobject.labelcaption |
|
|||
|
Thanks again, but I'm not quite with you. In the dbrepeater, I display the name (and then some other fields) and there could be a hundred or so in the list. The data comes from a query like "SELECT id, CONCAT(lastname,', ',firstname) AS fullname FROM customers", so the key is the id and the value is fullname, and there are 100 or so of the key/value pairs.
The label caption is set by the DataSource and DataField properties of the dbrepeater to "fullname" so that the names are displayed. Using your code, I can do something like this on the label's JS OnClick event: Code:
var target = event.target || event.srcElement; alert(target.innerHTML); How could I get the id?
__________________
If it was too easy it would be no fun |
|
||||
|
OK, visualize this pseudo code:
On the server in php code you either store an array as the labels are created or just run a loop with sql query later. Either way in one of the forms later events (onaftershow?) do a loop output of the value:key pairs. PHP Code:
Code:
var convertedname=string_manipulated(target.innerHTML ); alert(myinfo.convertedname); //this is the same as //alert(myinfo.Bloggs_Fred); //which displays 32441 Last edited by 405hp; 16th June 2008 at 20:44. |