faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 5 people (0%) answered Yes
Recently 0 of 5 people (0%) answered Yes

Entry

Is it possible to jump automatically to following textfields if the value of input field is equal 1

Aug 11th, 2006 16:18
David Alden, Harald S.,


yes it is :)
<html>
<script type="text/javascript" language="javascript">
	function changeSelection(event){
		if(event.keyCode == 49 && event.target.value == 1){
			document.thisForm.thisTextarea.select();
			document.thisForm.thisTextarea.focus();
		}
	}
</script>
	<form name="thisForm">
		<input type="text" name="thisText" 
onchange="changeSelection(event)" onkeyup="changeSelection(event)">
		    
		<textarea name="thisTextarea" >Some sample 
text</textarea>
	</form>
</html>