Hi there .. I have error on my firebug it says:document.getElementById("category") is null
Could someone help me??
and i wanted to set the default drop down option

<html>
	<head>
	<script type="text/javascript">
		var i = 0;
		var someValue = '4';
		var mySelect = document.getElementById('category');
		while(i < mySelect.options.length) {
		    if(mySelect.options[i].value == someValue) {
				mySelect.options[i].selected = true;
			}
			i++;
		}
	</script>
	</head>
	<body>
			<select id="category"> 
				<option value="1" >Статика</option>
				<option value="4">Статика2</option>
				<option value="7">Статика3</option> 
			</select> 
	</body>
</html>

Recommended Answers

All 3 Replies

I think you should add the javascript provided to a function then call the function using the body onload event, it will then work.

thanks you helped me::))

Pleasure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.