Help with using <form> for a search function, building a search query with drop downs |
Help with using <form> for a search function, building a search query with drop downs |
jaffs |
May 31 2009, 03:13 AM
Post
#1
|
Group: Members Posts: 2 Joined: 31-May 09 Member No.: 8,747 |
Hi guys,
I've used forms before to email collected information etc but I'm trying to do something a little different here and I can't work it out. I have a search.php function that works ok and I need to pass a search string to it like: <?s=hdtv+lcd+sony+42 I want to generate the "42" and "sony" from dropdown lists and the hdtv+lcd is fixed in the form. I can get the "hdtv+lcd" by using <input name="s" size="11" value="hdtv lcd" TYPE="hidden" /> but then using the <select></select> code for drop downs I end up with a search string of: <?s=hdtv+lcd&maker=Sony&size=42&s=Search Any help would be much appreciated Kev |
Christian J |
May 31 2009, 04:32 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
I need to pass a search string to it like: <?s=hdtv+lcd+sony+42 The "<" character shouldn't be there, otherwise the above should be the result of a single form field named "s", like CODE <input type="text" name="s" value="hdtv lcd sony 42"> See also http://en.wikipedia.org/wiki/Query_string#Structure QUOTE I want to generate the "42" and "sony" from dropdown lists and the hdtv+lcd is fixed in the form. I can get the "hdtv+lcd" by using <input name="s" size="11" value="hdtv lcd" TYPE="hidden" /> but then using the <select></select> code for drop downs I end up with a search string of: <?s=hdtv+lcd&maker=Sony&size=42&s=Search Every form element has its own NAME attribute, sounds like you want to combine only the values of several form elements without using their names. This is not directly possible, AFAIK, but you might let PHP (reliable) or javascript (not reliable) put the values together they way you want and send the result to the search function, or even better rewrite the search function. |
jaffs |
May 31 2009, 05:01 AM
Post
#3
|
Group: Members Posts: 2 Joined: 31-May 09 Member No.: 8,747 |
sounds like you want to combine only the values of several form elements without using their names. This is not directly possible, AFAIK, but you might let PHP (reliable) or javascript (not reliable) put the values together they way you want and send the result to the search function, or even better rewrite the search function. Thank Christian, I thought I was trying to oversimplify the issue. I'll have a look at creating a php solution. Kev |
Brian Chandler |
May 31 2009, 07:14 AM
Post
#4
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
sounds like you want to combine only the values of several form elements without using their names. This is not directly possible, AFAIK, but you might let PHP (reliable) or javascript (not reliable) put the values together they way you want and send the result to the search function, or even better rewrite the search function. Thank Christian, I thought I was trying to oversimplify the issue. I'll have a look at creating a php solution. Well, it's not even necessary to "create a php solution" -- all you need to do is modify the php script you have to accept the various inputs and assemble them into a single search string. If the program you have is properly documented and well orgainised, this should be very easy. (If it isn't well organised, I recommend throwing it away and finding a better one.) |
Lo-Fi Version | Time is now: 18th April 2024 - 11:49 PM |