Javascript - Function not defined error, Inputbux onclick sometimes gives function not defined error |
Javascript - Function not defined error, Inputbux onclick sometimes gives function not defined error |
Gooo |
Sep 21 2009, 04:53 AM
Post
#1
|
Novice Group: Members Posts: 23 Joined: 16-May 09 Member No.: 8,619 |
Hi,
I am trying to make a slide show of images with javascript. I don't want the page to refresh so I call document.write() every time the next and previous buttons is clicked. Onclick, I call a funcion that ajust the current frame number and call updte(currentFrame) that does document.write() and write the entire page. When the page is first loaded is calls CODE updte(1); CODE function updte(f) { document.write("<body bgcolor = '#000000' style='color:#ffffff' ><div align = 'center'><img src ='logo.jpg'/> <br /> <input type = 'button' value = 'Hide Descriptions' onclick = 'off()'/><input type = 'button' name = 'backward' value = '< previous frame' onClick = 'goBack()'><input onClick = 'goForward()' type = 'button' name = 'fowards' value = ' next frame >'><br /> <br /> <br /> <table border='0' align = 'center'><tr><td width='241' height='261' rowspan='2' valign = 'Top'><b>Brief description of action:</b><br /> "+actionArr[f]+" <br /> <b>Dialogue / Voiceover:</b><br /> "+ dialogueArr[f]+"<br /><b> Setting:</b><br /> "+setArr[f]+"<br /><b><br />Shot size:</b> "+sizeArr[f]+"</td><td width='332' height='67' valign = 'Top' align = 'center'><b>Number:</b><br /><b> Time: </b>"+TimeArr[f]+"</td> <td width='252' rowspan='2' valign = 'Top'><b>Camera movement:</b><br /> "+camMoveArr[f]+" <br /><b>Camera Angle:</b><br /> "+camAngArr[f]+" <b><br />Lighting:</b><br /> "+lightArr[f]+"<b><br />Props:</b> <br />"+ propArr[f]+"<b>Costume:</b> <br />"+cosArr[f]+"<b><br />Music:</b> <br />"+musicArr[f]+" <b><br />Sound FX</b><br />" +soundArr[f]+"</td></tr><tr><td height=296 width='380' valign = 'Top'><img name = 'change' src = '" + imageArr[f]+ " ' width='330' height='271' /></td> </tr></table></div>"); } CODE function goBack() { if (frame == 1 ) {frame = numFrames} else frame--; updte(frame); } function goForward() { if (frame == numFrames ) {frame = 1} else {frame++} updte(frame); } The problem is that I randomly get a goForward not defined error (mostly on the third or second click, but never on the first.) Please Help! |
Christian J |
Sep 21 2009, 05:41 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
I don't want the page to refresh so I call document.write() That sounds like a difficult solution. Why not just change the image SCR value instead? BTW if you want to write XHTML syntax, document.write is not allowed. QUOTE The problem is that I randomly get a goForward not defined error (mostly on the third or second click, but never on the first.) I get errors that the image arrays(?) actionArr etc are not defined. |
Gooo |
Sep 21 2009, 05:55 AM
Post
#3
|
Novice Group: Members Posts: 23 Joined: 16-May 09 Member No.: 8,619 |
QUOTE Why not just change the image SCR value instead? I used CODE document.images["change"].src = array[i] but I get exactly the same errors. The other problem is that the text around it has to change as well and I thougth it would just be easier to change everything in one call.Is there an alternative to document.write? QUOTE I get errors that the image arrays(?) actionArr etc are not defined. Thats because you don't have all my code. CODE var TimeArr = new Array(30); var actionArr = new Array(30); var dialogueArr = new Array(30); var sizeArr = new Array(30); var camMoveArr = new Array(30); var camAngArr = new Array(30); var lightArr = new Array(30); var setArr = new Array(30); var propArr = new Array(30); var cosArr = new Array(30); var musicArr = new Array(30); var soundArr = new Array(30); var imageArr = new Array(30); var numFrames; var frame = 1; |
Christian J |
Sep 21 2009, 04:38 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
|
Lo-Fi Version | Time is now: 25th April 2024 - 12:04 PM |