Arhtur_Barker
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Arhtur_Barker
-
-
Hi all,
I am fairly new to HTML/CSS and I am trying to make a quantity converter for food recipes as just a little challenge for myself. I think I have got most of the code down (I have created the basic function of the code, and got all the <input> and css write... I think) , but I am now stuck. At the moment in the they can only use one ingredient (or how many <inputs> I have put in there) but what I want to do is add a button which basically adds more inputs, so that they can add as many ingredients as they need.
How do I do this? (I have added what I have done below)
Cheers
Arthur
Audio problem
in JavaScript
Posted
Hi!
So I am new to coding and I am just trying to make a small project for myself. All it is a button that when you press it, it plays randomly one of three sounds. Something is going wrong though and I can't figure out what, anyone know?
<!doctype <!DOCTYPE html>
<link rel="stylesheet" href="C:\Users\Owner\Google Drive\Code\Experiments\HTML-CSS-JAVASCRIPT\Random Sound\Code\Random Sounds.css">
<h1> Random Sounds </h1>
<button id="press"> Press me! </button>
<script>
var num = 0
function pressed() {
num = Math.floor(1 + 3 * Math.random())
if (num == 1) {
var audio1 = new Audio('C:\Users\Owner\Google Drive\Code\Experiments\HTML-CSS-JAVASCRIPT\Random Sound\Sounds\OFFICIAL Somewhere over the Rainbow - Israel IZ Kamakawiwoʻole.mp3');
console.log('1')
audio1.play()
} else if (num == 2) {
var audio2 = new Audio('C:\Users\Owner\Google Drive\Code\Experiments\HTML-CSS-JAVASCRIPT\Random Sound\Sounds\OFFICIAL Somewhere over the Rainbow - Israel IZ Kamakawiwoʻole.mp3');
console.log('2')
audio2.play()
} else {
var audio3 = new Audio('C:\Users\Owner\Google Drive\Code\Experiments\HTML-CSS-JAVASCRIPT\Random Sound\Sounds\OFFICIAL Somewhere over the Rainbow - Israel IZ Kamakawiwoʻole.mp3');
console.log('3')
audio3.play()
}
}
press.onclick = pressed
</script>
cheers
A