How To Integrate The myHealthbox Search Bar Into Any Web Site

Release 1.0.1

21-06-2016

Before You Begin

This document is intended for website and mobile developers who want to use the healthcare products information supplied by the myHealthbox platform within their applications or services.

To use the myHealthbox Search Bar, you DO NOT need an API key.

Attribution

Any web or mobile applications using the myHealthbox Search Bar must display the “powered by myHealthbox” attribution and a link to the myHealthbox web site (myhealthbox.eu) in a suitable place.

Usage restrictions

If your myHealthbox Search Bar implementation generates a high volume of transactions, myHealthbox reserves the right to set transaction limits.


In your HTML code

Most implementations will use a form with an html code similar to the one shown below:


<!-- START myHealthbox Search Bar code -->

<form action="javascript:void(0);" class="content-search-view2">

<div class="input-group" >

<input id="search_bar" type="text" class="form-control" placeholder="" value="">

<span class="input-group-btn">

<button class="btn btn-primary" onclick="javascript:onSearchClick();">

<span class="glyphicon glyphicon-search" ></span>

</button>

</span>

</div>

</form>

<!-- END myHealthbox Search Bar code -->


There are several ways to implement a search bar, you can obviously modify the layout and the css to reflect the style of your site, just make sure you do not change the id of the input element ("search_bar").





The javascript code to build and call the search url is as follows:


// START myHealthbox Search Bar javascript code

var searchString = "";

$(document).ready(function () {

$('#search_bar').keypress(function(e) {

if(e.which == 13) {

onSearchClick();

}

});

});

function getSearchArray() {

return {

"q":searchString

};

}

function onSearchClick() {

searchString = $('#search_bar').val();

var formData = getSearchArray();

window.open(

"https://myhealthbox.eu/it/search.php?"+$.param(formData)+"&country=10&language=10",

'_blank'

);

}

// END myHealthbox Search Bar javascript code


The code above will create a form to input a text string (search string) and then open a new page with the list of the search results.


The new page will be under the myhealthbox.eu domain, if you are looking at managing the search query and the display of the result set within your site you will need to use the myHealthbox Web APIs.