-
Notifications
You must be signed in to change notification settings - Fork 0
/
cocktail.html
61 lines (50 loc) · 1.7 KB
/
cocktail.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<title>Test for API use</title>
<style>
input[name=ingredient1] {
color:blueviolet;
}
</style>
<script src="frontend/apirequest.js">
</script>
</head>
<body>
<form
name="ingredient"
id="ingredient"
>
<input type="hidden" name="query_string" id="fetch_request">
<div id="ingredients">
<input type="text" name="ingredient1">
<br>
</div>
<input type="button" value="Search cocktail!" onclick="apiFetch()">
</form>
<button onclick="add_ingredient()">+</button>
<script>
http_path = "https://www.thecocktaildb.com/api/json/v1/1/filter.php?";
function add_ingredient()
{
document.getElementById('ingredients').innerHTML += "<input type='text' name='ingredient1'><br>";
}
// function apiFetch()
// {
// var query_to_send = "";
// arr_ingredients = document.getElementsByName("ingredient1");
// for(var i = 0; i < arr_ingredients.length; i++)
// {
// if (arr_ingredients[i] != "")
// query_to_send += "i=" + arr_ingredients[i].value
// if(i != arr_ingredients.length - 1)
// query_to_send += "&";
// }
// var full_query = http_path + query_to_send;
// document.getElementById('fetch_request').value = full_query;
// console.log("hello")
// fetchInfo(full_query)
// }
</script>
</body>
</html>