JS function only works in one form (disables it on the others)

So I wanted to align my buttons according to the window size changes, I changed the code to JavaScript (NSB Doesn’t have what I need) and made a working code, and it’s what I need, and then I hopped into the next form, I started doing the thing and aligning and planning everything,

after I finished I went back to the first form, its not responding… anymore? I tried everything, it doesn’t read neither the JavaScript nor the BASIC codes, even when I change the language it from the Form settings

the other form I did is working as expected, not sure what’s going on, only the first form is not responding to any code whatsoever

After further analysis and troubleshooting to find the root of the problem, I found that the JS function:


only works in one form at a time (if I have 5 forms with it, all forms will stop and only one will use the function), please tell that there is a fix or a workaround for it

edit: also im not sure why everything broke, so I had to redo everything carefully to find the problem

It depends somewhat on how you’re doing the resizing. Are you doing it with html/css responsive elements, or are you changing the bounds of controls using JavaScript?

I’m using purely JavaScript, I just got into JS

Is there a way to do it with CSS (I’m not familiar with it)

There are a few articles in the blog about this:


If you look up Responsive Design on the web, you’ll find a ton of stuff. It’s by far the best way to do this.

But if you want to stick with doing it in JavaScript, call your control resizing code from each form’s onshow() event. That way it will get called when you change forms.

1 Like

The JavaScript worked nicely with that, I had the function already but never thought about nesting it :smiley:

Well I wish I could (and I want to) do CSS but my head is hurting already and I just need it for a homework, but that page sure looks interesting (I’ve only used the wiki)

Thanks for the help so far, it was really useful :heart:

Here’s an article in the Wiki: