Variables in another file won't display as an in shopping cart page












0















There are two main problems. First, I'm having trouble displaying the value of the item which should vary depending on the button selected. The innerHTML of the selected h3 element is supposed to enter into sessionStorage when activated from the source file. Then it's value goes to the receiving file as variable "ai" which will be appended as an li element into the unordered list of the page. The Second concern is the other function that the button in the source file performs. It's purpose is to alert that the item has been added to the shopping cart, but the function only displays in jsfiddle and not on glitch.com; where I'm creating the website. I believe it has something to do with the version of jquery the function uses or the source code. Any help on either of these is greatly appreciated.



Here is the source file...



Javascript/JQuery:



<script>
$(document).ready(function() {
var button = "none";
$(".button").click(function() {
button = $(this).attr("data-name");
alert(button);
});
});
function setWinHon() {
var i = document.getElementById("WinHon").innerHTML;
sessionStorage.setItem("item", i);
}
function setGolRod() {
var i = document.getElementById("GolRod").innerHTML;
sessionStorage.setItem("item", i);
}
function setMexPlu() {
var i = document.getElementById("MexPlu").innerHTML;
sessionStorage.setItem("item", i);
}
function setJasMin() {
var i = document.getElementById("JasMin").innerHTML;
sessionStorage.setItem("item", i);
}
function setCriTru() {
var i = document.getElementById("CriTru").innerHTML;
sessionStorage.setItem("item", i);
}
</script>


HTML:



</head>
<body>
<center>
<div id="text">
<div>
<div>
<h3 id="WinHon">Winter Honeysuckle $50</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera fragrantissima is a species of flowering plant in the honeysuckle family known by the common names winter honeysuckle, fragrant honeysuckle, January jasmine, Chinese honeysuckle, kiss-me-at-the-gate, and sweet breath of spring.
<button class="button" type="button" onclick="setWinHon()" data-name="Winter Honeysuckle">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FWinter%20Honeysuckle.jfif?1544561317954">
</div>
<div>
<div>
<h3 id="GolRod">Goldenrod $10</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Solidago, commonly called goldenrods, is a genus of about 100 to 120 species of flowering plants in the aster family, Asteraceae. Most are
herbaceous perennial species found in open areas such as meadows, prairies, and savannas.
<button class="button" type="button" onclick="setGolRod()" data-name="Goldenrod">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FGoldenrod.jpg?1544630990872">
</div>
<div>
<div>
<h3 id="MexPlu">Mexican Plum $30</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Prunus mexicana, commonly known as the Mexican plum, is a North American species of plum tree that can be found in the central United States and
Northern Mexico. Its native range stretches from Coahuila and San Luis Potosí north as far as Wisconsin and South Dakota, east to Georgia,
Kentucky, and Ohio.
<button class="button" type="button" onclick="setMexPlu()" data-name="Mexican Plum">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FMexican%20Plum.jfif?1544631101080">
</div>
<div>
<div>
<h3 id="JasMin">Jasmine $20</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Jasmine is a genus of shrubs and vines in the olive family. It contains around 200 species native to tropical and warm temperate regions of
Eurasia, Australasia and Oceania. Jasmines are widely cultivated for the characteristic fragrance of their flowers.
<button class="button" type="button" onclick="setJasMin()" data-name="Jasmine">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FJasmine.jpg?1544631121391">
</div>
<div>
<div>
<h3 id="CriTru">Crimson Trumpet $15</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera sempervirens is a species of honeysuckle native to the eastern United States. It can grow in many areas due to its hardiness. It is most
often grown as a plant for wildlife. Ruby-throated hummingbirds use it in their natural range as well as other birds, butterflies, and bees.
<button class="button" id="button5" type="button" onclick="setCriTru()" data-name="Crimson Trumpet">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FTrumpet%20Honeysuckle.jpg?1545705756174">
</div>
</div>
</center>
</body>


Here is the shopping cart (receiving file)...



<head>
<script>
function appendItems() {
var ai = sessionStorage.getItem("item");
ai = $("<li></li>").text("Text.");
$("ul").append(ai);
}
</script>
<div style="text-align:center;">
<h1>Shopping list</h1>
<p>So far you have ordered...</p>
</div>
</head>
<body>
<ul id="list">
<li></li>
</ul>
</body>


The shopping cart should produce an li element containing the value called by whichever button is selected and the button selected should alert "plantname" & " has now been added to your shopping cart!". However, nothing currently happens when the button is clicked










share|improve this question























  • Consider using data properties and a generic function that can use that data via jQuery rather than stamping out a function per entry here that's 99% the same as the others.

    – tadman
    Jan 2 at 20:30






  • 1





    Also since you're using jQuery, use jQuery. Don't mess around with the core JavaScript methods like document.getElementById("JasMin").innerHTML, when instead you can do the much more concise $('#JasMin').html()

    – tadman
    Jan 2 at 20:31


















0















There are two main problems. First, I'm having trouble displaying the value of the item which should vary depending on the button selected. The innerHTML of the selected h3 element is supposed to enter into sessionStorage when activated from the source file. Then it's value goes to the receiving file as variable "ai" which will be appended as an li element into the unordered list of the page. The Second concern is the other function that the button in the source file performs. It's purpose is to alert that the item has been added to the shopping cart, but the function only displays in jsfiddle and not on glitch.com; where I'm creating the website. I believe it has something to do with the version of jquery the function uses or the source code. Any help on either of these is greatly appreciated.



Here is the source file...



Javascript/JQuery:



<script>
$(document).ready(function() {
var button = "none";
$(".button").click(function() {
button = $(this).attr("data-name");
alert(button);
});
});
function setWinHon() {
var i = document.getElementById("WinHon").innerHTML;
sessionStorage.setItem("item", i);
}
function setGolRod() {
var i = document.getElementById("GolRod").innerHTML;
sessionStorage.setItem("item", i);
}
function setMexPlu() {
var i = document.getElementById("MexPlu").innerHTML;
sessionStorage.setItem("item", i);
}
function setJasMin() {
var i = document.getElementById("JasMin").innerHTML;
sessionStorage.setItem("item", i);
}
function setCriTru() {
var i = document.getElementById("CriTru").innerHTML;
sessionStorage.setItem("item", i);
}
</script>


HTML:



</head>
<body>
<center>
<div id="text">
<div>
<div>
<h3 id="WinHon">Winter Honeysuckle $50</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera fragrantissima is a species of flowering plant in the honeysuckle family known by the common names winter honeysuckle, fragrant honeysuckle, January jasmine, Chinese honeysuckle, kiss-me-at-the-gate, and sweet breath of spring.
<button class="button" type="button" onclick="setWinHon()" data-name="Winter Honeysuckle">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FWinter%20Honeysuckle.jfif?1544561317954">
</div>
<div>
<div>
<h3 id="GolRod">Goldenrod $10</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Solidago, commonly called goldenrods, is a genus of about 100 to 120 species of flowering plants in the aster family, Asteraceae. Most are
herbaceous perennial species found in open areas such as meadows, prairies, and savannas.
<button class="button" type="button" onclick="setGolRod()" data-name="Goldenrod">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FGoldenrod.jpg?1544630990872">
</div>
<div>
<div>
<h3 id="MexPlu">Mexican Plum $30</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Prunus mexicana, commonly known as the Mexican plum, is a North American species of plum tree that can be found in the central United States and
Northern Mexico. Its native range stretches from Coahuila and San Luis Potosí north as far as Wisconsin and South Dakota, east to Georgia,
Kentucky, and Ohio.
<button class="button" type="button" onclick="setMexPlu()" data-name="Mexican Plum">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FMexican%20Plum.jfif?1544631101080">
</div>
<div>
<div>
<h3 id="JasMin">Jasmine $20</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Jasmine is a genus of shrubs and vines in the olive family. It contains around 200 species native to tropical and warm temperate regions of
Eurasia, Australasia and Oceania. Jasmines are widely cultivated for the characteristic fragrance of their flowers.
<button class="button" type="button" onclick="setJasMin()" data-name="Jasmine">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FJasmine.jpg?1544631121391">
</div>
<div>
<div>
<h3 id="CriTru">Crimson Trumpet $15</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera sempervirens is a species of honeysuckle native to the eastern United States. It can grow in many areas due to its hardiness. It is most
often grown as a plant for wildlife. Ruby-throated hummingbirds use it in their natural range as well as other birds, butterflies, and bees.
<button class="button" id="button5" type="button" onclick="setCriTru()" data-name="Crimson Trumpet">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FTrumpet%20Honeysuckle.jpg?1545705756174">
</div>
</div>
</center>
</body>


Here is the shopping cart (receiving file)...



<head>
<script>
function appendItems() {
var ai = sessionStorage.getItem("item");
ai = $("<li></li>").text("Text.");
$("ul").append(ai);
}
</script>
<div style="text-align:center;">
<h1>Shopping list</h1>
<p>So far you have ordered...</p>
</div>
</head>
<body>
<ul id="list">
<li></li>
</ul>
</body>


The shopping cart should produce an li element containing the value called by whichever button is selected and the button selected should alert "plantname" & " has now been added to your shopping cart!". However, nothing currently happens when the button is clicked










share|improve this question























  • Consider using data properties and a generic function that can use that data via jQuery rather than stamping out a function per entry here that's 99% the same as the others.

    – tadman
    Jan 2 at 20:30






  • 1





    Also since you're using jQuery, use jQuery. Don't mess around with the core JavaScript methods like document.getElementById("JasMin").innerHTML, when instead you can do the much more concise $('#JasMin').html()

    – tadman
    Jan 2 at 20:31
















0












0








0








There are two main problems. First, I'm having trouble displaying the value of the item which should vary depending on the button selected. The innerHTML of the selected h3 element is supposed to enter into sessionStorage when activated from the source file. Then it's value goes to the receiving file as variable "ai" which will be appended as an li element into the unordered list of the page. The Second concern is the other function that the button in the source file performs. It's purpose is to alert that the item has been added to the shopping cart, but the function only displays in jsfiddle and not on glitch.com; where I'm creating the website. I believe it has something to do with the version of jquery the function uses or the source code. Any help on either of these is greatly appreciated.



Here is the source file...



Javascript/JQuery:



<script>
$(document).ready(function() {
var button = "none";
$(".button").click(function() {
button = $(this).attr("data-name");
alert(button);
});
});
function setWinHon() {
var i = document.getElementById("WinHon").innerHTML;
sessionStorage.setItem("item", i);
}
function setGolRod() {
var i = document.getElementById("GolRod").innerHTML;
sessionStorage.setItem("item", i);
}
function setMexPlu() {
var i = document.getElementById("MexPlu").innerHTML;
sessionStorage.setItem("item", i);
}
function setJasMin() {
var i = document.getElementById("JasMin").innerHTML;
sessionStorage.setItem("item", i);
}
function setCriTru() {
var i = document.getElementById("CriTru").innerHTML;
sessionStorage.setItem("item", i);
}
</script>


HTML:



</head>
<body>
<center>
<div id="text">
<div>
<div>
<h3 id="WinHon">Winter Honeysuckle $50</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera fragrantissima is a species of flowering plant in the honeysuckle family known by the common names winter honeysuckle, fragrant honeysuckle, January jasmine, Chinese honeysuckle, kiss-me-at-the-gate, and sweet breath of spring.
<button class="button" type="button" onclick="setWinHon()" data-name="Winter Honeysuckle">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FWinter%20Honeysuckle.jfif?1544561317954">
</div>
<div>
<div>
<h3 id="GolRod">Goldenrod $10</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Solidago, commonly called goldenrods, is a genus of about 100 to 120 species of flowering plants in the aster family, Asteraceae. Most are
herbaceous perennial species found in open areas such as meadows, prairies, and savannas.
<button class="button" type="button" onclick="setGolRod()" data-name="Goldenrod">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FGoldenrod.jpg?1544630990872">
</div>
<div>
<div>
<h3 id="MexPlu">Mexican Plum $30</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Prunus mexicana, commonly known as the Mexican plum, is a North American species of plum tree that can be found in the central United States and
Northern Mexico. Its native range stretches from Coahuila and San Luis Potosí north as far as Wisconsin and South Dakota, east to Georgia,
Kentucky, and Ohio.
<button class="button" type="button" onclick="setMexPlu()" data-name="Mexican Plum">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FMexican%20Plum.jfif?1544631101080">
</div>
<div>
<div>
<h3 id="JasMin">Jasmine $20</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Jasmine is a genus of shrubs and vines in the olive family. It contains around 200 species native to tropical and warm temperate regions of
Eurasia, Australasia and Oceania. Jasmines are widely cultivated for the characteristic fragrance of their flowers.
<button class="button" type="button" onclick="setJasMin()" data-name="Jasmine">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FJasmine.jpg?1544631121391">
</div>
<div>
<div>
<h3 id="CriTru">Crimson Trumpet $15</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera sempervirens is a species of honeysuckle native to the eastern United States. It can grow in many areas due to its hardiness. It is most
often grown as a plant for wildlife. Ruby-throated hummingbirds use it in their natural range as well as other birds, butterflies, and bees.
<button class="button" id="button5" type="button" onclick="setCriTru()" data-name="Crimson Trumpet">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FTrumpet%20Honeysuckle.jpg?1545705756174">
</div>
</div>
</center>
</body>


Here is the shopping cart (receiving file)...



<head>
<script>
function appendItems() {
var ai = sessionStorage.getItem("item");
ai = $("<li></li>").text("Text.");
$("ul").append(ai);
}
</script>
<div style="text-align:center;">
<h1>Shopping list</h1>
<p>So far you have ordered...</p>
</div>
</head>
<body>
<ul id="list">
<li></li>
</ul>
</body>


The shopping cart should produce an li element containing the value called by whichever button is selected and the button selected should alert "plantname" & " has now been added to your shopping cart!". However, nothing currently happens when the button is clicked










share|improve this question














There are two main problems. First, I'm having trouble displaying the value of the item which should vary depending on the button selected. The innerHTML of the selected h3 element is supposed to enter into sessionStorage when activated from the source file. Then it's value goes to the receiving file as variable "ai" which will be appended as an li element into the unordered list of the page. The Second concern is the other function that the button in the source file performs. It's purpose is to alert that the item has been added to the shopping cart, but the function only displays in jsfiddle and not on glitch.com; where I'm creating the website. I believe it has something to do with the version of jquery the function uses or the source code. Any help on either of these is greatly appreciated.



Here is the source file...



Javascript/JQuery:



<script>
$(document).ready(function() {
var button = "none";
$(".button").click(function() {
button = $(this).attr("data-name");
alert(button);
});
});
function setWinHon() {
var i = document.getElementById("WinHon").innerHTML;
sessionStorage.setItem("item", i);
}
function setGolRod() {
var i = document.getElementById("GolRod").innerHTML;
sessionStorage.setItem("item", i);
}
function setMexPlu() {
var i = document.getElementById("MexPlu").innerHTML;
sessionStorage.setItem("item", i);
}
function setJasMin() {
var i = document.getElementById("JasMin").innerHTML;
sessionStorage.setItem("item", i);
}
function setCriTru() {
var i = document.getElementById("CriTru").innerHTML;
sessionStorage.setItem("item", i);
}
</script>


HTML:



</head>
<body>
<center>
<div id="text">
<div>
<div>
<h3 id="WinHon">Winter Honeysuckle $50</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera fragrantissima is a species of flowering plant in the honeysuckle family known by the common names winter honeysuckle, fragrant honeysuckle, January jasmine, Chinese honeysuckle, kiss-me-at-the-gate, and sweet breath of spring.
<button class="button" type="button" onclick="setWinHon()" data-name="Winter Honeysuckle">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FWinter%20Honeysuckle.jfif?1544561317954">
</div>
<div>
<div>
<h3 id="GolRod">Goldenrod $10</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Solidago, commonly called goldenrods, is a genus of about 100 to 120 species of flowering plants in the aster family, Asteraceae. Most are
herbaceous perennial species found in open areas such as meadows, prairies, and savannas.
<button class="button" type="button" onclick="setGolRod()" data-name="Goldenrod">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FGoldenrod.jpg?1544630990872">
</div>
<div>
<div>
<h3 id="MexPlu">Mexican Plum $30</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Prunus mexicana, commonly known as the Mexican plum, is a North American species of plum tree that can be found in the central United States and
Northern Mexico. Its native range stretches from Coahuila and San Luis Potosí north as far as Wisconsin and South Dakota, east to Georgia,
Kentucky, and Ohio.
<button class="button" type="button" onclick="setMexPlu()" data-name="Mexican Plum">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FMexican%20Plum.jfif?1544631101080">
</div>
<div>
<div>
<h3 id="JasMin">Jasmine $20</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Jasmine is a genus of shrubs and vines in the olive family. It contains around 200 species native to tropical and warm temperate regions of
Eurasia, Australasia and Oceania. Jasmines are widely cultivated for the characteristic fragrance of their flowers.
<button class="button" type="button" onclick="setJasMin()" data-name="Jasmine">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FJasmine.jpg?1544631121391">
</div>
<div>
<div>
<h3 id="CriTru">Crimson Trumpet $15</h3>
<ul style="list-style-type:none" class="align" align="left">
<li>Height:</li>
<li>Width:</li>
<li>Maintenance:</li>
<li>Environment:</li>
<li>Nomenclature:</li>
</ul>
<p class="div1">Lonicera sempervirens is a species of honeysuckle native to the eastern United States. It can grow in many areas due to its hardiness. It is most
often grown as a plant for wildlife. Ruby-throated hummingbirds use it in their natural range as well as other birds, butterflies, and bees.
<button class="button" id="button5" type="button" onclick="setCriTru()" data-name="Crimson Trumpet">Buy Now!</button></p>
</div>
<img src="https://cdn.glitch.com/9c36ac94-6707-41ee-a6b7-a39f46cd02e3%2FTrumpet%20Honeysuckle.jpg?1545705756174">
</div>
</div>
</center>
</body>


Here is the shopping cart (receiving file)...



<head>
<script>
function appendItems() {
var ai = sessionStorage.getItem("item");
ai = $("<li></li>").text("Text.");
$("ul").append(ai);
}
</script>
<div style="text-align:center;">
<h1>Shopping list</h1>
<p>So far you have ordered...</p>
</div>
</head>
<body>
<ul id="list">
<li></li>
</ul>
</body>


The shopping cart should produce an li element containing the value called by whichever button is selected and the button selected should alert "plantname" & " has now been added to your shopping cart!". However, nothing currently happens when the button is clicked







javascript jquery session-cookies shopping-cart






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 20:27









Chasten MusendaChasten Musenda

11




11













  • Consider using data properties and a generic function that can use that data via jQuery rather than stamping out a function per entry here that's 99% the same as the others.

    – tadman
    Jan 2 at 20:30






  • 1





    Also since you're using jQuery, use jQuery. Don't mess around with the core JavaScript methods like document.getElementById("JasMin").innerHTML, when instead you can do the much more concise $('#JasMin').html()

    – tadman
    Jan 2 at 20:31





















  • Consider using data properties and a generic function that can use that data via jQuery rather than stamping out a function per entry here that's 99% the same as the others.

    – tadman
    Jan 2 at 20:30






  • 1





    Also since you're using jQuery, use jQuery. Don't mess around with the core JavaScript methods like document.getElementById("JasMin").innerHTML, when instead you can do the much more concise $('#JasMin').html()

    – tadman
    Jan 2 at 20:31



















Consider using data properties and a generic function that can use that data via jQuery rather than stamping out a function per entry here that's 99% the same as the others.

– tadman
Jan 2 at 20:30





Consider using data properties and a generic function that can use that data via jQuery rather than stamping out a function per entry here that's 99% the same as the others.

– tadman
Jan 2 at 20:30




1




1





Also since you're using jQuery, use jQuery. Don't mess around with the core JavaScript methods like document.getElementById("JasMin").innerHTML, when instead you can do the much more concise $('#JasMin').html()

– tadman
Jan 2 at 20:31







Also since you're using jQuery, use jQuery. Don't mess around with the core JavaScript methods like document.getElementById("JasMin").innerHTML, when instead you can do the much more concise $('#JasMin').html()

– tadman
Jan 2 at 20:31














0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012719%2fvariables-in-another-file-wont-display-as-an-li-in-shopping-cart-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012719%2fvariables-in-another-file-wont-display-as-an-li-in-shopping-cart-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

The term 'EXEC' is not recognized as the name of a cmdlet Powershell

NPM command prompt closes immediately [closed]

Error binding properties and functions in emscripten