Created
April 10, 2012 12:25
-
-
Save alistairstead/2351041 to your computer and use it in GitHub Desktop.
Node-1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Node-1</title> | |
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script> | |
<link rel="stylesheet" href="http://yuilibrary.com/yui/docs/assets/node/node.css"> | |
</head> | |
<body> | |
<form id="demo" action="#"> | |
<label>Width:</label> | |
<input name="width" size="2"> | |
<input type="submit" value="Run"> | |
</form> | |
<script type="text/javascript"> | |
YUI().use('node', function(Y) { | |
var form = Y.one('#demo'), | |
input = Y.one('#demo input[name=width]'), | |
button = Y.one('#demo input[type=submit]'); | |
form.on('submit', function(e) { | |
e.preventDefault(); // keep the form from submitting | |
var value = input.get('value'), | |
width = form.get('offsetWidth'); | |
if (value == '') { | |
input.set('value', width); | |
} else if (!isNaN(parseInt(value))) { | |
form.set('offsetWidth', value); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment