Sha256: 113e448a616d6c10f48a14a43c2a35609a0e8d2a8b3d09ab45373610c6fc3915

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

<html>
<head>
<title>Server Side Autocompletion</title>
<script type="text/javascript" src="js/ajax.js">#{}</script>
<script type="text/javascript">

function hit() {
	ajax_get('hit?val=' + document.getElementById('hitval').value);
	return false;
}

function getWord(input, evt) {
	if (input.value.length == 0) {
		return;
	}

	//allow backspace to work in IE

	if (typeof input.selectionStart == 'undefined' && evt.keyCode == 8) { input.value = input.value.substr(0,input.value.length-1); }

	// Ignore the following keystrokes

  switch (evt.keyCode) {
    case 37: //left arrow
    case 39: //right arrow
    case 33: //page up  
    case 34: //page down  
    case 36: //home  
    case 35: //end
    case 13: //enter
    case 9:  //tab
    case 27: //esc
    case 16: //shift  
    case 17: //ctrl  
    case 18: //alt  
    case 20: //caps lock
    case 8:  //backspace  
    case 46: //delete 
    case 38: //up arrow 
    case 40: //down arrow
      return;
		break;
 	}

	lastLength = input.value.length;

	word = ajax_get('get_word?word=' + input.value) 

	if (word.length > 1) {
		input.value = word
		try {
			input.setSelectionRange(lastLength, input.value.length);
		} catch(e) {
		}
	}
}

</script>
</head>
<body>
<h1>Server side autocompletion</h1>
<form>
<b>Enter a Country:</b> <input type="text" id="country" name="country" value="" onkeyup="getWord(this,event)" autocomplete="off" />
<br />
try one of #{COUNTRIES.join(', ')}
</form>
<h1>Send data to a server action</h1>
<p>
	<input id="hitval" type="text" value="Test" /> <a href="#" onclick="hit()">Send</a>
</p>
</body>
</html>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.16.0 examples/ajax/public/index.xhtml
nitro-0.17.0 examples/ajax/public/index.xhtml