Jump to content

[SOLVED] Object has no properties


xiao

Recommended Posts

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.