SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
May 8, 2007, 01:44 #1
- Join Date
- Aug 2004
- Location
- San Clemente, CA
- Posts
- 859
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Insert search variable with radio buttons
o Keyword
o Exact Phrase
Search: |______________|
[SUBMIT]
I have an internal search bar with two radio buttons and an input box in which the radio buttons allow the user to do a general keyword search or search by an exact phrase. Pending on which radio is checked, will determine which search page it should go to.
I am trying to insert the search criteria from an input box into the GET url in the radio value ie- /page.php?search="$search".
How can I fill the below $search variable with the vaule from the input box on submit (see red areas below)?
Code:<script type="text/javascript"> function funct_WhereToGo() { var obj_RadioButton = window.document.theFORM.rb_Select; for (var i = 0; i < obj_RadioButton.length; i++) {if (obj_RadioButton[i].checked == true) {window.location = obj_RadioButton[i].value;} } } </script> <form name="theFORM" method="get"> <INPUT TYPE="RADIO" NAME="rb_Select" ID="rb_Select1" VALUE="/emt/test/member_emt2.php?search='$search'"> Keyword<BR> <INPUT TYPE="RADIO" NAME="rb_Select" ID="rb_Select2" VALUE="/emt/test/member_emt3.php?search='$search'"> Exact Phrase <br> <!-- the value of this input box needs to fill the above $search in red --> <input name="search33" type="text" id="search33" size="27"> <INPUT TYPE="BUTTON" onClick="funct_WhereToGo();" VALUE=">"> </form>
-
May 8, 2007, 04:45 #2
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
You're going about this the wrong way. The current radio buttons' value is probably a minor security concern. Your search page ought to be "search.php" and you should be passing the search keywords and what search type to use. So the URL would end up being:
HTML Code:search.php?keywords=buffalo+meat+jerky&searchtype=exact
-
May 8, 2007, 06:02 #3
- Join Date
- Apr 2007
- Posts
- 813
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
agree, pretty url should be good design pattern to go about.
Bookmarks