0

hi

i want to check off a checkbox while i'm typing. for an example if i'm typing "oranges are good" and i have oranges, apples, and blueberry under my check box. i want oranges to be checked of as soon as i type oranges in my phrase "oranges are good". i'm trying to do this using jquery. if you can help please reply

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by hielo
1

if keyup does not work, try keypress :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>hielo</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
	$('#description').bind('keyup',function(){
		var val=this.value;
		$('input[name=fruit]').each(function(){
				this.checked=val.indexOf(this.value)>-1;
		});
	});
});
</script>
	</head>
	<body>
	<div><input type="checkbox" name="fruit" value="orange"/>Oranges</div>
	<div><input type="checkbox" name="fruit" value="apple"/>Apple</div>
	<div><textarea name="description" id="description" rows="7" cols="50"></textarea></div>
	</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.