Zoekfunctie met selectmenu waarbij de database er al staat, kan dit?

Status
Niet open voor verdere reacties.

richard5000

Gebruiker
Lid geworden
24 mrt 2012
Berichten
161
Ik heb onderstaande zoekfunctie code2, welke op zich werkt, maar ik wil graag dat hij via een puldown menu alleen zoekt in de kolommen die je aangeeft via een puldownmenu, dus Search: <geef hier wat je zoekt> in <selectiemenu, bv kolomnaam 1 en kolomnaam 2) Hier de Search button.

Nu heb ik iets:

Code:
<h2>Search</h2> 
 <form name="search" method="post" action="<?=$PHP_SELF?>">
 Seach for: <input type="text" name="find" /> in 
 <Select NAME="field">
 <Option VALUE="naam">Naam</option>
 <Option VALUE="lname">Last Name</option>
 </Select>
 <input type="hidden" name="searching" value="yes" />
 <input type="submit" name="search" value="Search" />
 </form>

Maar dit krijg ik niet in onderstaande zoekfunctie:


[CODE2] <script language="javascript" type="text/javascript">
//define the table search as an object, which can implement both functions and properties
window.tableSearch = {};

//initialize the search, setup the current object
tableSearch.init = function() {
//define the properties I want on the tableSearch object
this.Rows = document.getElementById('data').getElementsByTagName('TR');
this.RowsLength = tableSearch.Rows.length;
this.RowsText = [];

//loop through the table and add the data to
for (var i = 0; i < tableSearch.RowsLength; i++) {
this.RowsText = (tableSearch.Rows.innerText) ? tableSearch.Rows.innerText.toUpperCase() : tableSearch.Rows.textContent.toUpperCase();
}
}

//onlys shows the relevant rows as determined by the search string
tableSearch.runSearch = function() {
//get the search term
this.Term = document.getElementById('textBoxSearch').value.toUpperCase();

//loop through the rows and hide rows that do not match the search query
for (var i = 0, row; row = this.Rows, rowText = this.RowsText; i++) {
row.style.display = ((rowText.indexOf(this.Term) != -1) || this.Term === '') ? '' : 'none';
}
}

//runs the search
tableSearch.search = function(e) {
//checks if the user pressed the enter key, and if they did then run the search
var keycode;
if (window.event) { keycode = window.event.keyCode; }
else if (e) { keycode = e.which; }
else { return false; }
if (keycode == 13) {
tableSearch.runSearch();
}
else { return false; }
}
</script>[/CODE2]
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan