How can I change a value in an array?

JavaScript Cannot Set 'value' of undefined?

  • Hey guys, I was wondering if you could look at my code and explain why line 49 won't work. My slideshow won't change the slide numbers, making each slide valued at 1 when you hit the next or previous button and I can't figure out why. I tried searching for an answer, but couldn't find anything. Thanks for looking at this. I inserted where the error is as (ERROR IS HERE) but it isn't actually written in the file. Just wanted to make it easy to find. Also it should say ".value" after the "document.slidecontrols.currentslide" part in the error. Not sure why it won't let me change that. <html> <head> <title>Blankety Blank Blank </title> <script language="javascript" type="text/javascript"> <!-- var mySlides=new Array(); mySlides[1]=new Image(); mySlides[2]=new Image(); mySlides[3]=new Image(); mySlides[4]=new Image(); mySlides[5]=new Image(); mySlides[6]=new Image(); mySlides[1].src="she.jpg"; mySlides[2].src="sells.jpg"; mySlides[3].src="seashells.jpg"; mySlides[4].src="by.jpg"; mySlides[5].src="the.jpg"; mySlides[6].src="seashore.jpg"; var myCaptions = new Array(); myCaptions[1] = "secret1."; myCaptions[2] = "secret2."; myCaptions[3] = "secret3."; myCaptions[4] = "secret4."; myCaptions[5] = "secret5."; myCaptions[6] = "secret6."; var slidenumber=1; var totalslides=mySlides.length - 1; function showSlide(direction){ if(direction=="next"){ (slidenumber==totalslides)? slidenumber = 1:slidenumber++; }else{ (slidenumber==1)?slidenumber = totalslides:slidenumber--; } document.slideframe.src=mySlides[sli… document.slidecontrols.caption.value = myCaptions[slidenumber]; document.slidecontrols.currentslide.… = slidenumber; (ERROR IS HERE--^) } //--> </script> </head> <body> <div align="center"> <h2> Photos from Blankety Blank </h2> <table border="0"> <tr> <td> <img src="she.jpg" name="slideframe" alt="Slideshow images appear here."/> </td> </tr> <tr> <td> <form name="slidecontrols"> <p> <textarea name="caption" rows="2" cols="50"> This is super secret info ;D. </p> </textarea> <input type="button" value="Previous Slide" onclick="showSlide('previous');" /> <input type="button" value="Next Slide" onclick="showSlide('next');" /> <p> Slide Number: <input type="text" value="1" name="Current Slide" size="5" /> </p> </form> </td> </tr> </div> </body> </html>

  • Answer:

    Change this: <input type="text" value="1" name="Current Slide" size="5" /> To this: <input type="text" value="1" name="currentslide" size="5" />

Tyler at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.