# Change src dynamically

**URL:** <https://phaser.discourse.group/t/change-src-dynamically/10246>\
**Category:** Phaser 3\
**Created:** [September 14, 2021, 5:14pm UTC](https://phaser.discourse.group/t/change-src-dynamically/10246 "2021-09-14T17:14:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ederish\_Herrera](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/ederish_herrera/32/5534_2.png) [@Ederish\_Herrera](https://phaser.discourse.group/u/Ederish_Herrera)\
**Post date:** [September 14, 2021, 5:14pm UTC](https://phaser.discourse.group/t/change-src-dynamically/10246/1 "2021-09-14T17:14:21Z")

</div>

suppose an audio

```javascript
this.load.audio('song1','assets/audio/level-1.mp3');

```

and convert the url to a variable

```javascript
this.load.image('img1', songURL);

var songURL = 'assets/img/lofi-1.jpg';

```

 ![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/9/91a50e243f4d7924eb92482e27c48e1dc6053b92.jpeg)

How do I change the value of the variable when I click on one of the boxes?  
I tried with:

```javascript
r1.on('pointerdown', () => songURL ="'assets/audio/level-1.mp3'" )

```

and with :

```javascript
r1.on('pointerdown', () => songURL.src ="'assets/audio/level-1.mp3'" )

```
