Jump to content

How to set/change TGroupBox.Caption with javascript


irigsoft

Recommended Posts

Hello everyone.

I need to set a value to TGroupBox2.Caption on Client side and after that check it on Server Side without ajax events.

I have :

1. TGroupBox2.jsID = "tform_clientservice_tgroupbox2_0"

2. On FormCreate I set TGroupBox2.Caption: = '.';
2. I can change the caption on the client side with AddJS ("document.getElementById" ("tform_clientservice_tgroupbox2_0-legendTitle"). InnerHTML = "some new caption value";);

3. Now I have to check the value of the caption on the server side, but I always get the caption = '.'.
 

How to change with javascript TGroupBox.Caption on the client side and get the correct (new) value on the server side without ajax events?

 

In this picture are New value after addJS and old value (as I get it from the server)

image.thumb.png.8c449e3214b338577abdb2fc461eb77b.png

Link to comment
Share on other sites

22 minutes ago, Sherzod said:

Hello, 

In short, no way.

Okay, is there a way to get the value of cookies for a session from the server?

The new value of TGroupBox.Caption is read / write cookie, how do I read this cookie value from the server for this session?

I know this UniGUIApplication.UniApplication.Cookies.SetCookie('UNI_GUI_SESSION_ID',UniSession.UniApplication.Cookies.GetCookie ('UNI_GUI_SESSION_ID'),0,True,True,'/');

 

but is there a way to do this for different sessions. Some of them will not have this cookie, others will have different values ?

I want to use this cookie to save user data as a "first name" and each time it loads my URL, the application will check for this cookie and say hello: "First name" and other things will be done on the server side.

Link to comment
Share on other sites

7 hours ago, irigsoft said:

Okay, is there a way to get the value of cookies for a session from the server?

Yes.

7 hours ago, irigsoft said:

but is there a way to do this for different sessions. Some of them will not have this cookie, others will have different values ?

If you mean different workstations, then yes, they will be different.

7 hours ago, irigsoft said:

How to change with javascript TGroupBox.Caption on the client side and get the correct (new) value on the server side without ajax events?

And what bothers you, if you are worried about traffic, actually a little data is sent to the server here.

Link to comment
Share on other sites

10 minutes ago, Sherzod said:

And what bothers you, if you are worried about traffic, actually a little data is sent to the server here.

Hello.

1. My problem is that: I have a dll on the server (external dll). In this dll I have a function in which I run addJS.

I do this: When a client clicks a button, this button has an onClick event on the server side, this event performs functions from the dll.

All the functionality is created in an external designer (I made my own designer of features and screen elements, so I can do many different designs just with the designer and they will all work without writing a single line of code additionally)

Now in my new case. I need to save information from the client and I can save it in a cookie or localstorage.

1. So when the customer first loads my URL, I will ask him for the phone number

2. I save this number in a cookie

3. The next time the client loads a URL, I will check for this cookie and get this value and set it in my TGroupBox.Caption.

4. When the client works with my application on the server side, I need to be able to read this value of TGroupBox.Caption and use it when working with the functions in external dll.


Once again the problem is that I am using a design application and this designer has an addJS function on it, so I can use many different javascript functions dynamically, but I can't do an onajax event for each component in the form.

 

What about : how to get/change aria-label value from image ?

Link to comment
Share on other sites

38 minutes ago, Sherzod said:

If you mean different workstations, then yes, they will be different.

In my case I have many sessions, they all have a cookie: phoneID. Each session (client) will set its own phoneID = own phone number.

When I request a cookie value from the server, what value will I get from the session, the one for the session I am asking for, or a list of all phoneID values?

If I use this code for this purpose is it OK ?:

UniSession.UniApplication.Cookies.GetCookie ('phoneID'),0,True,True,'/');

Link to comment
Share on other sites

9 minutes ago, irigsoft said:

How ?

Also you can use like this:

UniSession.UniApplication.Cookies.Values['phoneID'];

For example, demo:

\FMSoft\Framework\uniGUI\Demos\Desktop\LoginForm Cookies
procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject;
  var Handled: Boolean);
var
  S1, S2 : string;
begin
  S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname'];
  S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd'];

  Handled := SameText(S1, 'demo') and SameText(S2, 'demo');

  if Handled then
    LoggedUser := S1;
end;

 

  • Like 1
Link to comment
Share on other sites

5 hours ago, Sherzod said:

Also you can use like this:

UniSession.UniApplication.Cookies.Values['phoneID'];

For example, demo:

\FMSoft\Framework\uniGUI\Demos\Desktop\LoginForm Cookies
procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject;
  var Handled: Boolean);
var
  S1, S2 : string;
begin
  S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname'];
  S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd'];

  Handled := SameText(S1, 'demo') and SameText(S2, 'demo');

  if Handled then
    LoggedUser := S1;
end;

 

One more question, how to delete Cookie ?

UniApplication.Cookies.SetCookie('_loginname', '', 0,/);  is it enough ?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...