KEYWORDS: suggestive text, javascript, autocomplete, completing text in javascript.
<!--AUTOCOMPLETE DEMONSTATION BY SAURAJEET DUTTA
Birla Institute Of Technology, Mesra, Ranchi
Feb 28, 2011
This code is only made to test the autocompleting procedure from one word "saurajeet"
this code has to be modified for a list of word...
-->
<script type="text/javascript">
document.onkeyup = KeyCheck;
function KeyCheck(e)
{
var KeyID = (window.event) ? event.keyCode : e.keyCode;
switch(KeyID)
{
case 13: if (document.getElementById("suggest").innerHTML == "<no suggest>")
break;
else
{ document.getElementById("typepad").value = document.getElementById("suggest").innerHTML;
return;
}
}
}
function suggest(str)
{ document.getElementById("ff").innerHTML = str.length;
var suggest = "saurajeet";
if (matched (suggest, str))
{ document.getElementById("suggest").innerHTML = suggest;
}
else
{ document.getElementById("suggest").innerHTML = "<no suggest>";
}
return;
}
function matched (a, b)
{ if (b.length < 4)
{ return false;
}
for (var i = 0; i < b.length; i++)
{ if (a[i] != b[i])
return false;
}
return true;
}
</script>
<input type="text" name="MyText" id='typepad' onkeyup="suggest(this.value)" onchange="" />
<strong id="ff">0</strong>
<strong>, Suggestive Text </strong> <label id="suggest">No Suggestion</label>
<pre>
1. Enter the string "saur" into the textbox
2. Once the suggestive Text changes Appears in
3. press enter to complete the string
Note: This code is only made with to work with one word change the program accordingly for a list of words..
HOPE I HAVE FULFILLED SOME OF YOUR EXPECTATIONS
</pre>
Save the following code as an html file and run it in any browser
CODE
<!--AUTOCOMPLETE DEMONSTATION BY SAURAJEET DUTTA
Birla Institute Of Technology, Mesra, Ranchi
Feb 28, 2011
This code is only made to test the autocompleting procedure from one word "saurajeet"
this code has to be modified for a list of word...
-->
<script type="text/javascript">
document.onkeyup = KeyCheck;
function KeyCheck(e)
{
var KeyID = (window.event) ? event.keyCode : e.keyCode;
switch(KeyID)
{
case 13: if (document.getElementById("suggest").innerHTML == "<no suggest>")
break;
else
{ document.getElementById("typepad").value = document.getElementById("suggest").innerHTML;
return;
}
}
}
function suggest(str)
{ document.getElementById("ff").innerHTML = str.length;
var suggest = "saurajeet";
if (matched (suggest, str))
{ document.getElementById("suggest").innerHTML = suggest;
}
else
{ document.getElementById("suggest").innerHTML = "<no suggest>";
}
return;
}
function matched (a, b)
{ if (b.length < 4)
{ return false;
}
for (var i = 0; i < b.length; i++)
{ if (a[i] != b[i])
return false;
}
return true;
}
</script>
<input type="text" name="MyText" id='typepad' onkeyup="suggest(this.value)" onchange="" />
<strong id="ff">0</strong>
<strong>, Suggestive Text </strong> <label id="suggest">No Suggestion</label>
<pre>
1. Enter the string "saur" into the textbox
2. Once the suggestive Text changes Appears in
3. press enter to complete the string
Note: This code is only made with to work with one word change the program accordingly for a list of words..
HOPE I HAVE FULFILLED SOME OF YOUR EXPECTATIONS
</pre>
No comments:
Post a Comment