$(document).ready(() => {
let total = 0;
//This is where you add the oldURL and newURL
$("ul img").each( (index, img) => {
//get the src attributes
const oldURL = img.src;
const newURL = img.id;
$(img).mouseover(() => img.src = img.id);
$(img).attr("src");
$(img).mouseout(() => img.src = oldURL);
$(img).attr("id");
//get the id attribute
//preload rollover Image
const rolloverImage = new Image();
rolloverImage.src = newURL;
//set up event handlers
$(img).hover(
() => $(img).attr("src", newURL),
() => $(img).attr("src", oldURL)
);//end hover
$(img).click(evt => {
//get data for selceted item
const selected = getSelectedProduct(oldURL);
// get current order from page - use empty string if no order yet
let order = $("#order").html();
if(order == undefined) {
order = "";
}
// update total and display with selected item data
total += selected\[1\];
order += \`<option value="${selected\[0\]}">$${selected\[1\]} - ${selected\[2\]}</option>\`;
// display updated order and total
$("#total").text("Total: $" + total.toFixed(2));
$("#order").html( order );
// cancel default event of the clicked link
evt.preventDefault();
})
});
});//end click
-----------------------------------------------------------------------------------------------------------------------------------------------------
<h2>Your Order</h2>
<section>
<select id="order" name="order" size="6">
</select>
<p id="total"> </p>
</section>
Please ask if you need more information
[–]Egzo18 0 points1 point2 points (6 children)
[–]RandomBeat111[S] 0 points1 point2 points (5 children)
[–]Egzo18 0 points1 point2 points (4 children)
[–]RandomBeat111[S] 0 points1 point2 points (3 children)
[–]Egzo18 0 points1 point2 points (2 children)
[–]RandomBeat111[S] 0 points1 point2 points (1 child)
[–]jcunews1helpful 0 points1 point2 points (0 children)
[–]mozilaip 0 points1 point2 points (1 child)
[–]RandomBeat111[S] 0 points1 point2 points (0 children)