Jump to content

Can you search multiple fields?


This topic is 8444 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have looked around but I can't find the answer I am looking for.

I want to have a person search several fields in my database but only enter one text string. I would like to have radio buttons saying for example "search answer only", "search question only", "search both q & a". Can anyone help me figure this out?

Thanks.

Link to comment
Share on other sites

quote:

Originally posted by texaschick:

I have looked around but I can't find the answer I am looking for.

I want to have a person search several fields in my database but only enter one text string. I would like to have radio buttons saying for example "search answer only", "search question only", "search both q & a". Can anyone help me figure this out?

Thanks.

texaschick,

I would create calculated fields in my database. These fields only purpose would be to combine the data from several different fields and display them. For example I could create a field called "Answer Calc", set it as calculation and define it as such:- Answer1&" "&Answer2&" "&Answer3

where "Answer1", "Answer2", "Answer3" are different fields in the database. I would set the result as text or whatever (depending on the data in the answer fields). Finally in the search page I would let them search this field.

Hope this helps.

Link to comment
Share on other sites

Here is the HTML page with the javascript to do what you want:

<html>

<head>

<script>

function setChoice(choice){

switch(choice){

case (0) ???

document.yourForm.answer.value="";

document.yourForm.question.value="";

break;

case (1) :

document.yourForm.answer.value=document.yourForm.searchText.value;

document.yourForm.question.value="";

break;

case (2) :

document.yourForm.answer.value="";

document.yourForm.question.value=document.yourForm.searchText.value;

break;

case (3) :

document.yourForm.answer.value=document.yourForm.searchText.value;

document.yourForm.question.value=document.yourForm.searchText.value;

}

}

</script>

</head>

<body>

<form name="yourForm">

Type your search criteria here: <input type="text" name="searchText" value="" size=20>

and then

<select NAME="choice" onChange="setChoice(this.selectedIndex)">

<option selected>--Select search option-- 

<option>search answer only 

<option>search question only 

<option>search both 

</select>

<br>

Answer: <input type="text" name="answer" value="" size=20> (this would be a hidden field)

<br>

Question: <input type="text" name="question" value="" size=20> (this would be a hidden field)

<br>

<INPUT TYPE="Reset" VALUE="Clear this form">

</form>

</body>

</html>

Link to comment
Share on other sites

This topic is 8444 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.