Skip to content

Instantly share code, notes, and snippets.

@goodwill
Created March 29, 2009 07:35
Show Gist options
  • Save goodwill/87324 to your computer and use it in GitHub Desktop.
Save goodwill/87324 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>dependent_control</title>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<script type="text/javascript" charset="utf-8">
$.fn.extend({dependent:function() {
var $this=$(this);
$this.live('keypress', function(){
var $dependent=$($(this).attr('dependent'));
$dependent.val($(this).val());
})
}});
$(document).ready(function() {
$('#text1').dependent();
})
</script>
</head>
<body>
<input id="text1" dependent="#text2" />
<input id="text2" />
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment