Forum Moderators: open
it working well with textfied
<td><b>KEYWORDS</b><input type="text" size="17" name="text1" value""></td>
<td><input type="button" value="Search"
onclick="search_db(text1.value)"></td>
if i want to search with combobox like
<b>SHOW ME JOBS FROM</b><br/>
<select name="time[]" >
<option value="any3">Any</option>
<option value="a2">3 days ago</option>
<option value="b2">Last Week </option>
<option value="c3">Last Month</option>
</select>
What i have to do? is it:
input " type="button" value="Search"
onclick="search_db(time[a2].value)"></td>"
my code for search is:
<script language="JavaScript"><!--
var items_found=0;
var rowsdb=2;// rows number (DATABASE)
var colsdb=3;// columns number (DATABASE)
var rowsres=100; // rows number (RESULT)
var colsres=2; // cols number (RESULT)
var numkeys=1; // max keys to search for// make an Array object initialized by blanks
// (this array is your DATABASE)celldb=new Array(rowsdb);
for (i=0; i<=rowsdb; i++){celldb[i]=new Array(colsdb)
for (j=0;j<=colsdb; j++) {celldb[i][j]=" "}
}// make an Array object initialized by blanks
// (this array will contain items matched; i.e.: RESULT)cellres=new Array(rowsres);
for (i=0; i<=rowsres; i++){cellres[i]=new Array(colsres);
for (j=0;j<=colsres; j++) {cellres[i][j]=" "}
}celldb[0][0]="accouting";
celldb[0]="javascript cource fsdfsd";
celldb[0][2]="Javasc.htm";celldb[1][0]="javascript";
celldb[1][1]="Javascript course";
celldb[1][2]="Javasc.htm";// display result
function display_result(items_found) {
mywindow=window.open("","help","toolbar=0,location=0,*
directories=0,status=0,menubar=0,scrollbars=1,resizable=1,*
copyhistory=0,width=500,height=255,screenX=200,screenY=100");
mywindow.document.write("<HTML><HEAD>");
mywindow.document.write("<TITLE>Help</TITLE>");
mywindow.document.write('</HEAD><BODY');
mywindow.document.write("<center>Items found: " + items_found + "</center><br><hr>");
items_found--;
for (i=0;i<=rowsres;i++){
mywindow.document.write
(cellres[i][1]+"<br>"+cellres[i][0] + "</a><br>");
if (i==items_found){i=rowsres;i++};
};
mywindow.document.write("<hr><center><FORM>*
<INPUT TYPE='button' VALUE='Close' onClick='window.close()'></FORM>");
mywindow.document.write("</CENTER>");
mywindow.document.write("</BODY></HTML>");
mywindow.document.close();}
//search the DATABASE arrayfunction search_db(key1)
{key1=key1.toLowerCase();
var items_found=0;
for (i=0;i<rowsdb;i++)
{if (celldb[i][0]==key1)
{cellres[items_found][0]=celldb[i][1];
cellres[items_found][1]=celldb[i][2];
items_found++;}
}
if (items_found==0)
{alert("Sorry, no item matched your search...")}
else
{display_result(items_found)};
}// End -->
</script>Note:
* = line break added to stop side-scrolling in this thread
[1][edited by: tedster at 7:58 am (utc) on Oct. 6, 2003]
I don't think you'd want to use square brackets as part of the name= attribute. Wouldn't you just declare name="time" and then say onclick="search_db(time.value)"
Without knowing exactly how you're going to search the data for "time" ("time" must be a specific field, I assume) it's hard to be precise.