PDA

View Full Version : a search box with drop down options



rich1234
08-07-2008, 08:22 PM
Hi, I have different content on different pages.
I have search boxes which search each content and the results as they are different get directed to different pages.
Is there a script on dynamic drive that has a dropdown options combined with the search box so you could select what area you wish to search. I cannot find one but have seen one on a delicious http://delicious.com/popular/linux
Thanks
Richard

Nile
08-08-2008, 01:18 PM
You mean like something that happens when you type in a users name in the "User Name:" input on this page:
http://www.dynamicdrive.com/forums/search.php
Or something more like:
http://www.dynamicdrive.com/dynamicindex5/overlapcontent.htm

rich1234
08-13-2008, 07:30 PM
Dear Nile, Not exactly, really like this
http://www.javascriptkit.com/script/cut130.shtml

but where the form action is changed dependant on selection.
Thanks
Richard

rich1234
08-13-2008, 07:56 PM
Hi actually I found this and got it working but need a drop down in place of the radio buttons. Any ideas about altering the javascript?


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title><script src="/js/validatesearch.js" type="text/javascript"></script>
</head>

<body>
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2003 Bontrager Connection, LLC
// See article "Changing Form Action URLs On-The-Fly" linked
// from URL /library/archives
// for more information about how to use this code.
function ActionDeterminator()
{
if(document.myform.reason[0].checked == true) {
document.myform.action = '/search.asp';
}
if(document.myform.reason[1].checked == true) {
document.myform.action = '/businesssearch.asp';
}
if(document.myform.reason[2].checked == true) {
document.myform.action = 'artschoolsearch.asp';
}
return true;
}
// -->
</script>

<form name="myform" method="post" action="search.asp" onsubmit="return validate_form(this)">

<input type="text" size="12" name="SearchWord" style="border: 0px solid #000; padding: 0pt; background-color: #c0c0c0; margin-left: 0px; margin-right: 0px; vertical-align: middle;">


<input type="radio" checked name="reason">art
<input type="radio" name="reason">business
<input type="radio" name="reason">tips

<input onClick="return ActionDeterminator();" value="search" type="submit" style="border: 0px solid #000; padding: 1px 2px; background-color: #808080;margin-left: 1px; vertical-align: middle; font-size: 10px; font-family: Verdana;" >

</form>
</body>

</html>

Thanks
Richard

TheJoshMan
08-13-2008, 08:46 PM
I'm no javascript guru, but you might give this a shot...




<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title><script src="/js/validatesearch.js" type="text/javascript"></script>
</head>

<body>
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2003 Bontrager Connection, LLC
// See article "Changing Form Action URLs On-The-Fly" linked
// from URL /library/archives
// for more information about how to use this code.
function ActionDeterminator()
{
if(document.myform.reason[0].selected == true) {
document.myform.action = '/search.asp';
}
if(document.myform.reason[1].selected == true) {
document.myform.action = '/businesssearch.asp';
}
if(document.myform.reason[2].selected == true) {
document.myform.action = 'artschoolsearch.asp';
}
return true;
}
// -->
</script>

<form name="myform" method="post" action="search.asp" onsubmit="return validate_form(this)">

<input type="text" size="12" name="SearchWord" style="border: 0px solid #000; padding: 0pt; background-color: #c0c0c0; margin-left: 0px; margin-right: 0px; vertical-align: middle;">

<select>
<option selected name="reason">art</option>
<option name="reason">business</option>
<option name="reason">tips</option>
</select>

<input onClick="return ActionDeterminator();" value="search" type="submit" style="border: 0px solid #000; padding: 1px 2px; background-color: #808080;margin-left: 1px; vertical-align: middle; font-size: 10px; font-family: Verdana;" >

</form>
</body>

</html>