xiao Posted April 16, 2008 Share Posted April 16, 2008 I have something that looks like this: <html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function veranderAfbeelding() { var begin = document.behuizing.value.search(/>>>/); var einde = document.behuizing.value.search(/<<</); document.afbeelding.src = document.behuizing.options[document.behuizing.selectedIndex].value.substring(begin,einde); } function vorigeAfbeelding() { if(document.behuizing.selectedIndex != 0) { document.behuizing.selectedIndex--; } veranderAfbeelding(); } function volgendeAfbeelding() { if(document.behuizing.selectedIndex != document.behuizing.options.length-1) { document.behuizing.selectedIndex++; } veranderAfbeelding(); } // End --> </script> </head> <body onLoad="javascript:veranderAfbeelding()"> <form action="" method="POST"> <select name="behuizingprijs"> <option value="0">tot €50</option> <option value="50">€50 tot €75</option> <option value="75">€75 tot €100</option> <option value="100">€100 tot €150</option> <option value="150">> €150</option> </select> <img name="afbeelding" src="1.gif"> <input type="button" value="<" onclick="javascript:vorigeAfbeelding()"> <select name="behuizing" class="behuizing" onchange="javascript:veranderAfbeelding()"> <option value="10 - DVD-UNSG2 - 29.9900 - Under Siege 2 - Dark Territory - >>>dvd/under_siege2.gif<<<">Under Siege 2 - Dark Territory - 29.9900</option> </select> <input type="button" value=">" onclick="javascript:volgendeAfbeelding()"> And I get this error from FireBug: document.behuizing has no properties var begin = document.behuizing.value.search(/>>>/); I get the same type of error when I click those buttons, so I'm probably doing the same thing wrong a couple of times. Quote Link to comment Share on other sites More sharing options...
haku Posted April 16, 2008 Share Posted April 16, 2008 Try this: var begin = document.behuizing.selectedIndex.value Quote Link to comment Share on other sites More sharing options...
xiao Posted April 16, 2008 Author Share Posted April 16, 2008 But I need the search() thingy I tried this: var begin = document.behuizing.selectedIndex.value.search(/>>>/); But it still says document.behuizing has no properties Quote Link to comment Share on other sites More sharing options...
xiao Posted April 16, 2008 Author Share Posted April 16, 2008 edit: sorry, still not working Quote Link to comment Share on other sites More sharing options...
haku Posted April 16, 2008 Share Posted April 16, 2008 My point was that you were missing selectedIndex. When you say its still not working, are you getting the same error message, or something different? Quote Link to comment Share on other sites More sharing options...
xiao Posted April 16, 2008 Author Share Posted April 16, 2008 This works (the original script), but only when I remove the doctype... <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="author" content="joske"> <title>Untitled 1</title> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function changeImage() { mainimage.src = list.options[list.selectedIndex].value; } function prevImage() { if(list.selectedIndex == 0) { list.selectedIndex = list.options.length-1; } else { list.selectedIndex--; } changeImage(); } function nextImage() { if(list.selectedIndex == list.options.length-1) { list.selectedIndex = 0; } else { list.selectedIndex++; } changeImage(); } // End --> </script> </head> <BODY onLoad="javascript:changeImage()"> <center> <img name="mainimage" border="1" src="1.gif"> <br> <input type="button" value="Terug" onclick="javascript:prevImage()"> <select id="list" onchange="javascript:changeImage()"> <option value="1.gif">Eerste Image</option> <option value="2.gif">Tweede Image</option> <option value="3.gif">Derde Image</option> <option value="4.gif">Vierde Image</option> <option value="5.gif">Vijde Image</option> </select> <input type="button" value="Volgende" onclick="javascript:nextImage()"> </body> </html> Quote Link to comment Share on other sites More sharing options...
haku Posted April 16, 2008 Share Posted April 16, 2008 Did you not see my last question? Quote Link to comment Share on other sites More sharing options...
xiao Posted April 16, 2008 Author Share Posted April 16, 2008 Yea, I read it. But I tried this: var begin = document.behuizing.selectedIndex.value.search(/>>>/); and it still says document.behuizing has no properties So it's still the same error. Quote Link to comment Share on other sites More sharing options...
xiao Posted April 16, 2008 Author Share Posted April 16, 2008 got it working. I gave the <select> also an id="behuizing" and used this: var begin = behuizing.options[behuizing.selectedIndex].value.search(/>>>/); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.