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
Related Q & A:
- How to return a value from .ashx file to javascript in a variable?Best solution by forums.asp.net
- How to pass javascript jQuery variable value in php array?Best solution by Stack Overflow
- how to use javascript variable value in jsp?Best solution by Stack Overflow
- How to set value in the dropdown from a JSON data list?Best solution by Stack Overflow
- how to set value in ckeditor using jquery?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.