# Js function with parameters

**URL:** <https://www.phphelp.com/t/js-function-with-parameters/34296>\
**Category:** Javascript & Ajax\
**Created:** [November 23, 2021, 11:57am UTC](https://www.phphelp.com/t/js-function-with-parameters/34296 "2021-11-23T11:57:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anette](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Anette](https://www.phphelp.com/u/Anette)\
**Post date:** [November 23, 2021, 11:57am UTC](https://www.phphelp.com/t/js-function-with-parameters/34296/1 "2021-11-23T11:57:03Z")

</div>

Hello!  
How can I make a button increase date by 1?  
It should work for red and green simultaneously.

Can I do a function in funk?  
And how do I access it whitout id?

function funk(id){  
const date = new Date();

if(id=1){ show date in red, in div a}  
if(id=2){ show date in green, in div b }  
}

I simplified the code, funk is working with multiple id’s.

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [November 23, 2021, 2:01pm UTC](https://www.phphelp.com/t/js-function-with-parameters/34296/2 "2021-11-23T14:01:17Z")

</div>

- please code between [code] [ /code [ tags

- increase by ‘1’…what? second? minute? day? month? year?

- red & green… what? buttons?

- what is ‘funk’?

- provide the layout/DOM for this DIV a and DIV b

---

<div class="post-metadata">

**Author:** ![Anette](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Anette](https://www.phphelp.com/u/Anette)\
**Post date:** [November 24, 2021, 11:17am UTC](https://www.phphelp.com/t/js-function-with-parameters/34296/3 "2021-11-24T11:17:08Z")

</div>

increase by 1, is what it says, increase the **date by 1**.  
the color is just to show that the function does different things when the function is called with different id’s.  
funk is just the name on the function, it could be anything.
