Jump to content

Javascript Objects Help


pxxb

Recommended Posts

Hi, I am fairly new to JavaScript and am looking for some help with a practice website. The website advertises food and when the user clicks the next button, the image of the food, and price change. This is what I have so far, I have an idea on how to go about doing this. Maybe make a loop and every time the button next is pressed increase the array by 1? Any help would be wonderful, thanks.

 
<html>
<body>
<h1> Amy's Bakery</h1>
 
<h2>Prices at: <span id='price'>$14.99</span</h2>
 
<img id = 'picture' src='images/chocolatecake.jpg' alt='' />
 
<a href='#' id= 'PrevBtn'>Previous</a>
 
<a href='#' id= 'NextBtn'>Next</a>
 
<div class='desc'>
Freshly backed Chocolate Cake
</div>
 
<script type='text/javascript'>
var dessertArray = Array(
{
imgSrc : 'images/chocolatecake.jpg',
desc : 'Freshly backed chocolate cake.',
price : 'price : $14.99'
},
{
imgSrc : 'images/chocolatemuffin.jpg',
desc : 'Delicious chocolate muffin',
price : 'price : $2.99'
},
{
imgSrc : 'images/icecream.jpg',
desc : 'Delicious ice cream available in multiple flavours.',
price : 'price : $4.99'
},
{
imgSrc : 'images/cheesecake.jpg',
desc : 'Delicious apple cheesecake',
price : 'price : $149,999.00'
}
);
 
</body>
</html>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.