Help with JavaScript...

ko.

Member
I'm trying to finish an assignment for class and I'm having trouble with swapping images - any help would be great!

and +k of course :)
 
Do you mean java, or javascript?
Because you would use the onMouseClick attribute to relay to your next picture.
while(x.onmouseclick = true) image x = image y; break;

 
of course, that's assuming you wanted mouseclick images swapped. I'm not going to get into animated threads for javascript swapping. It's more than I care to code late at night for someone who clearly needs to pay more attention in class.
 
it's an online class...and the prof doesn't include great examples...but thanks.

it's supposed to be a function swap () with two drop down menus to switch images...

these are the "directions" :

[*]
  1. Begin with an implementation of swap that looks like this:
  2. function swap ()

    {

    var indexA = 0;

    alert(indexA);

    }
  3. In between the two statements, put some code that stores

  4. 0 in indexA if "Upper Left" is selected in the first menu,

  • 1 in indexA if "Upper Right" is selected in the first menu,
  • 2 in indexA if "Lower Left" is selected in the first menu, or
  • 3 in indexA if "Lower Right" is selected in the first menu.

  1. This code should deal only with indexA and the first menu; it shouldn't refer to the second menu or the images.
  2. When you've done this correctly, you'll see the correct value of indexA pop up when you select from the first menu and click "Swap". When it is working correctly, get rid of the alert().


[*]
  1. You've now written the first block of code. Write a second block of code that declares a variable indexB and stores

  2. 0 in indexB if "Upper Left" is selected in the second menu,

  • 1 in indexB if "Upper Right" is selected in the second menu,
  • 2 in indexB if "Lower Left" is selected in the second menu, or
  • 3 in indexB if "Lower Right" is selected in the second menu.

  1. This code should deal only with indexB and the second menu; it shouldn't refer to the first menu or the images.

  2. Now your function is able to determine the indexes (indexA and indexB) of the two images (which are stored in the array document.images) that need to be swapped. The third block should be the code that actually swaps them. This code should deal only with indexA, indexB, and the images; it shouldn't refer to either menu.

...if this makes any sense to anyone?
 
that makes perfect sense, actually. He walks you through every step like you're children. Why don't you learn basic javascript and come back when you need actual help, not someone holding your hand.
 
i'm TRYING to learn basic javascript. it's why i'm taking the class. because i know NOTHING about it.

any chance you would like to help a girl out instead of just pointing and laughing?
 
I am very firm when it comes to coding about learning for yourself what you're capable of. It is an art, and a science.
http://www.w3schools.com/js/default.asp
there. have at it. It has nothing to do with your femininity, it has everything to do with the fact that your professor basically walked you through the layout and classes.
 
Back
Top