Page 1 of 1

Javascript, get option value

Posted: Tue Dec 21, 2010 7:31 pm
by JKM

Code: Select all

#...
<head>
#...
<script type="text/javascript">
	function customCheck() {
			var select = GkForm.GkCodeType.options[GkForm.GkCodeType.selectedIndex];
			var hidden = document.getElementById('customWrap');
			if(select.value == 'custom'){				
				hidden.style.display = '';
			} else {
				hidden.style.display = 'none';
			}
		}
</script>
</head>
#...
<form action="" method="post" name="GkForm" id="GkForm">
	<select name="GkCodeType" onchange="customCheck()">
		<option value="random">Random</option>
		<option value="custom">Custom</option>
	</select>
	<div id="customWrap" style="display: none;">
		<input type="text" maxlength="20" name="customCode" />
	</div>
</form>
#...
returns 'GkForm is not defined'...

Re: Javascript, get option value

Posted: Tue Dec 21, 2010 9:37 pm
by califdon
Try document.GkForm.GkCodeType.options[documentGkForm.GkCodeType.selectedIndex]

Re: Javascript, get option value

Posted: Wed Dec 22, 2010 5:32 am
by JKM
califdon wrote:Try document.GkForm.GkCodeType.options[documentGkForm.GkCodeType.selectedIndex]
It worked - thanks a lot! :)