Skip to content
Advertisement

How to pass 1 argument each from 2 functions into 1 function?

I’ve tried to understand how and why I haven’t seen any answers to this specific question.

I have two functions each has an argument path

JavaScript
JavaScript

Just ignore everything these functions actually do, cause everything works just perfectly until I want to pass on name & site to the following create_new_sbb function

JavaScript

So I want to pass on these arguments to create_new_sbb at the same time, instead of calling create_new_sbb on each function

Note that create_new_sbb is located in another file

The results in MySql DB:

enter image description here

I want site and name on the same row obviously
So only execute create_new_sbb when both arguments have been passed somehow.

Any help is very appreciated!!!

Advertisement

Answer

I will assume here that you always call check_sbb_name and check_sites_for_sbb in pairs with the same path. I would use:

JavaScript

The important part is to register elements and only write to the database when you have a pair. Alternative methods (using same principle) could be used if for example you always call check_sbb_name first, then register_name would always register cur_name (no need for path) and register_site would always call create_new_bb. Or…

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement