Click to See Complete Forum and Search --> : quick button


vinsa
08-15-2003, 06:30 AM
Hello!
First sorry for my English.
This is my dictionary.
I want when I press "Enter"
button on the keyboard to
start function SearchAble1().
I try whit this script:
==============================
<script>
function execOnEnter(){
if(event.keyPress=="13"){SearchAble1();}
else{return false;}
}
document.onkeypress=execOnEnter;
</script>
=============================
but it not work.

This is my webpage:

<html>
<head>
<title>My Dictionary</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">

<script type="text/javascript">
<!--
function SelectBase() {

Ba = document.myForm.keyword.value.indexOf("a",0)
Bb = document.myForm.keyword.value.indexOf("b",0)
Bc = document.myForm.keyword.value.indexOf("c",0)

if (Ba == 0) {
return inconstant = base_a;
}

if (Bb == 0) {
return inconstant = base_b;
}

if (Bc == 0) {
return inconstant = base_c;
}

}

page="<html><head><title>Search Results</title></head><body bgcolor='white' leftmargin=3 topmargin=3 text='blue'><center><table border=0 cellspacing=0 cellpadding=0 width=100%><font face=Arial size=3>";

function SearchAble1() {
if (document.myForm.keyword.value == ""){
win = parent.middle("","secId5874","scrollbars=1");
win.document.write("write something");
win.document.close();
}
else{
Searching();
}
}

function SearchAble2() {
invalidChars = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÜÚÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùü/úþÿ.,!?;:1234567890~@#$%^&*()_+=¹[]{}§"

for (i=0; i<invalidChars.length; i++) {
badChar = invalidChars.charAt(i)
if (document.myForm.keyword.value.indexOf(badChar,0) > -1) {
document.myForm.keyword.value = "";
}
}

}

function Searching() {
inconstant = SelectBase();
win = parent.middle("","secId5874","scrollbars=1");
win.document.write(page);
inconstant.recordset.MoveFirst();
for (var i = 1; i <= inconstant.recordset.AbsolutePosition; i++) {
if(inconstant.recordset("first")<=document.myForm.keyword.value.toLowerCase()) {
win.document.write(inconstant.recordset("last")+", ");
win.document.write("</font></table></body></html>");
win.document.close();
}
inconstant.recordset.MoveNext();
}
}


function Clear() {
win = parent.middle("","secId5874","scrollbars=1");
win.document.write(page);
win.document.close();
document.myForm.keyword.value = "";
}

//-->
</script>



</head>
<body>
<!-- Data source object: file parameters -->
<object id="base_a" width="0" height="0" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="base_a.txt">
<param name="FieldDelim" value=";">
<param name="UseHeader" value="true">
</object>

<object id="base_b" width="0" height="0" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="base_b.txt">
<param name="FieldDelim" value=";">
<param name="UseHeader" value="true">
</object>

<object id="base_c" width="0" height="0" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="base_c.txt">
<param name="FieldDelim" value=";">
<param name="UseHeader" value="true">
</object>


<h2>Searching in my DICTIONARY</h2>
<form name="myForm">
Query a key word: <input onKeyUp="SearchAble2()" id="keyword" value="" /><button onClick="SearchAble1()">search</button>
<button onclick="Clear();">Clear</button>
</form>



<IFRAME name="middle" width="250" height="300" src="nach.html" frameborder=0 style="border-style: inset; border-width: 2px"></IFRAME>

</body>
</html>

vinsa
08-15-2003, 07:44 AM
Hi agian.
I find this script:
========================
<script type="text/javascript">
<!--

var hotkey=104
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function backhome(e){
if (document.layers){
if (e.which==hotkey)
SearchAble1();
}
else if (document.all){
if (event.keyCode==hotkey)
SearchAble1();
}
}
document.onkeypress=backhome

//-->
</script>
==========================

It work but only when the mouse is not
in the textarea. When the mouse is in the textarea
=> the page refreshing or something such.
How can I edit the script so that
when the mouse is in the textarea
to start function SearchAble1()
without page refreshing.
Please for tip.