# Use Javascript with Hubl

**URL:** <https://community.hubspot.com/t/use-javascript-with-hubl/32304>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [February 25, 2021, 12:17pm UTC](https://community.hubspot.com/t/use-javascript-with-hubl/32304 "2021-02-25T12:17:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgoodman](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sgoodman/32/73373_2.png) [@sgoodman](https://community.hubspot.com/u/sgoodman)\
**Post date:** [February 25, 2021, 12:17pm UTC](https://community.hubspot.com/t/use-javascript-with-hubl/32304/1 "2021-02-25T12:17:42Z")

</div>

Hi everyone.

I have cloned the Search Results template to make some adjustments. Instead of searching my blogs by keyword, I want to find the input and then send that input to some Hubl code where I can display blogs with tags matching the input. For example, If I input ‘trends’ in my search, I’d like the search results page to display blogs that have trends as a tag.

I’m wondering if this is possible as in the module, the javascript is in the module.js section whereas everything else is in the HTML / Hubl section. Is there a way I can do this? See below for an example of what I’m trying to acheive:

```lia-code-sample
function httpRequest(term, offset) {
var SEARCH_URL = '/_hcms/search?',
requestUrl = SEARCH_URL + searchParams + '&analytics=true',
request = new XMLHttpRequest();
request.open('GET', requestUrl, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);

findTags(data.searchTerm);
} else {
console.error('Server reached, error retrieving results.');
}
};
request.onerror = function() {
console.error('Could not reach the server.');
};
request.send();
}

```

```lia-code-sample
findTags(input) {
//Here, I want to be able to somehow do a hubl function to display blogs with tags

{% related_blog_posts tags={{ TAGS FOUND IN JS CODE }} %}

}

```

Does anyone know if this is possible?

Thanks

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [February 25, 2021, 2:58pm UTC](https://community.hubspot.com/t/use-javascript-with-hubl/32304/2 "2021-02-25T14:58:28Z")

</div>

It’s not possible to use Javascript inside HubL code as HubL is server-side code that runs before any Javascript does. You can use HubL to get url search query though.

`{% related_blog_posts tags="{{ request.query_dict.term }}" %}`

---

<div class="post-metadata">

**Author:** ![sgoodman](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sgoodman/32/73373_2.png) [@sgoodman](https://community.hubspot.com/u/sgoodman)\
**Post date:** [February 25, 2021, 6:33pm UTC](https://community.hubspot.com/t/use-javascript-with-hubl/32304/3 "2021-02-25T18:33:01Z")

</div>

Thank you this is exactly what I was looking for
