how to use JS in outsystems

how to use JS in outsystems

  
As subject, I don't known how to get the "id" or "class" of one widget 
Hi Zhou,

Welcome to the OutSystems community!

When you name an UI object (e.g. Container) you can reference it on the javascript (jquery) by doing something like this (on an unexcaped expression):

"<script> alert($('#"+ObjectName.Id+"').text());</script>"
- ObjectName.Id will represent the generated runtime id for that object.

You can also add a class in the "Style" attribute of the object and do something like:

"<script> alert($('.MyClassName').text());</script>"

If you are coding the javascript on the block/page javascript you have to pass this Id to the method, or use the class.

I hope it helps.

regards,
HD
Hélio Dolores wrote:
Hi Zhou,

Welcome to the OutSystems community!

When you name an UI object (e.g. Container) you can reference it on the javascript (jquery) by doing something like this (on an unexcaped expression):

"<script> alert($('#"+ObjectName.Id+"').text());</script>"
- ObjectName.Id will represent the generated runtime id for that object.

You can also add a class in the "Style" attribute of the object and do something like:

"<script> alert($('.MyClassName').text());</script>"

If you are coding the javascript on the block/page javascript you have to pass this Id to the method, or use the class.

I hope it helps.

regards,
HD
 Thanks for your reply,it is very helpful to me.