Div (container) with fixed id?

Div (container) with fixed id?

Hi there!

Is there any way of creating a div (container) in OutSystems, with fixed id?

I have 2 div's inside header, but id's are being created like wt_CompoundWebwidget654647_wtcurrent_time, when I just wanted current_time. That shouldn't be a problem, but from WebScreen to WebScreen the widget number changes slightly...

I need that, because I have a JS function with uses getElementById, in order to show the current time, in real time, updated second by second, in format H:M:S, with leading zeros.

I tried getElementByName (just forcing it for testing, I know name is for form elements) and added name in Title to Extended Properties with "current_time" in Value, but it doesn't work, although 'name="current_time="' it's in div tag.

Thanks for your time and help.
Hi Luís,

Can you pass the ID as an argument to your JavaScript function? You access the Container's ID in Expression Editor --> Widgets --> Container's Name --> Id

Hope it helps.

Thanks for the help Fernando.

I thought that, but just the header has the div's id, which strangely is different in different webscreens which is included... I have the onload = "callfunction();" in body, on each webscreen, which calls the function, but as the id is not the same, the getElementById works only where id is correct...

The only element in header where I can use the onload, is an image, but that's so against the standards, that I prefer not to do that...

The function fills in 2 divs, one with the date (formatted in a specific way) and the other div with the current time, both updated in real time... If you have another way of doing it, I would appreciate to hear it. Unfortunately, I don't have another way, this function has worked before, it still works, but this dynamic id thing is really annoying...
I tried this:

1 - I created 2 Session variables, current_date_id and current_time_id.
2 - I created a Screen Preparation on the Header, in which I assign the div's id's (widget id) into both session variables
3 - I call the function with onload title, in each Web Screen, with the value being the function calling, with both variables as arguments.

But it works on one screen, but header isn't reloaded when exchanging screens, so the widget changes value, but the screen preparation doesn't run, which makes the widget's id's different...

Any idea?
Hi there,

I'm not quite sure i understood your problem but :

I see two and half probable solutions for your situation :

1st : have a local variable on your webscreen, assigned to a hidden input widget, and then inside your weblock, fill out that input (which can be an input parameter of your webblock)

Pass the value has an input parameter to your other screen.

half :

Instead of a local variable, use the session variable. Afterwards the only thing to do would be not to overwrite your session variable.

2nd :

Instead of using a container use a no-escape expression beginning the div "<div id='wtCurrentTime'>" and another at the end of it... "</div>"

I guess this would do the trick.

Best Regards,

Diogo C S Cordeiro
Diogo C S Cordeiro, that last solution, the one of the expression without escaping contents, worked like a charm. It was so simple, but I never thought of that.

Thanks a lot for everybody's help. You've been great, I've learned a few tricks with all of your hints.