johnnybebad Posted May 8, 2010 Share Posted May 8, 2010 Hi can anyone tell me if I have something wrong in my files relating to checbox and radio buttuns. it appears that I can switch on and off with a checbox, box with a tick/ empty box radio though appaers to to be emoty on first oage load, once selected it remains selected ie circle goes from empty to blue filled and you cant get it to unselct at all. I checked the html_output function and it appears to be the same for each box other than ones labelled up raiod and the other checkbox. Is there anywhere else this is set at the end of the day all its saying is on/off and using two icons to indicate the current status. so somewhere in the system something must set how a radio and checbox actually funtion and it doent appear tobe in the html-output file as the code is the same but the beaviour is different. Thanks Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 8, 2010 Author Share Posted May 8, 2010 Hi can anyone tell me if I have something wrong in my files relating to checbox and radio buttuns. it appears that I can switch on and off with a checbox, box with a tick/ empty box radio though appaers to to be emoty on first oage load, once selected it remains selected ie circle goes from empty to blue filled and you cant get it to unselct at all. I checked the html_output function and it appears to be the same for each box other than ones labelled up raiod and the other checkbox. Is there anywhere else this is set at the end of the day all its saying is on/off and using two icons to indicate the current status. so somewhere in the system something must set how a radio and checbox actually funtion and it doent appear tobe in the html-output file as the code is the same but the beaviour is different. Thanks heres the html output code //// // Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field() function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') { global $HTTP_GET_VARS, $HTTP_POST_VARS; $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"'; if ( ($checked == true) || (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name]) && (($HTTP_GET_VARS[$name] == 'on') || (stripslashes($HTTP_GET_VARS[$name]) == $value))) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name]) && (($HTTP_POST_VARS[$name] == 'on') || (stripslashes($HTTP_POST_VARS[$name]) == $value))) ) { $selection .= ' CHECKED'; } if (tep_not_null($parameters)) $selection .= ' ' . $parameters; $selection .= '>'; return $selection; } //// // Output a form checkbox field function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') { return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters); } //// // Output a form radio field function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') { return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters); } Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
acbatchelor Posted May 8, 2010 Share Posted May 8, 2010 you can't unselect a radio button. radio buttons are used when an option MUST be selected. so if you select one after the page loads, you can select another radio button but not unselect it. checkboxes are used if more than one option can be selected or if selecting an option isn't necessary. change the radio buttons to checkboxes if you want to uncheck. you could also make one of the radio buttons give the user the option to choose nothing. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 8, 2010 Author Share Posted May 8, 2010 you can't unselect a radio button. radio buttons are used when an option MUST be selected. so if you select one after the page loads, you can select another radio button but not unselect it. checkboxes are used if more than one option can be selected or if selecting an option isn't necessary. change the radio buttons to checkboxes if you want to uncheck. you could also make one of the radio buttons give the user the option to choose nothing. I have seen a site where the radio buttons are selected as either or, and when you select the other one the previous option is unselected but the code I have just lets you select optio after option until they are all selected, you dont have to select them all to do the search though. So dont know how to go about this at all have to change the code? but how, I posted the code on another thread or at least parts of it on how I got to where I am at. To be fair I be happy to use checkboxs but they would have to look like radio buttons, is that possible? Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
acbatchelor Posted May 8, 2010 Share Posted May 8, 2010 checkboxes and radio buttons get their look from the web browser. they look a little different if you view them in a different web browser. so there is no way to make checkboxes look like radio buttons. if the page is letting you select multiple radio buttons then it must not know that the radio buttons are grouped together. the radio buttons must be in the same form. this is an example of the radio buttons in the same form; however, this is a pure HTML example and not a PHP example. <form> <input type="radio" name="sex" value="male" /> Male <br /> <input type="radio" name="sex" value="female" /> Female </form> Link to comment Share on other sites More sharing options...
johnnybebad Posted May 10, 2010 Author Share Posted May 10, 2010 checkboxes and radio buttons get their look from the web browser. they look a little different if you view them in a different web browser. so there is no way to make checkboxes look like radio buttons. if the page is letting you select multiple radio buttons then it must not know that the radio buttons are grouped together. the radio buttons must be in the same form. this is an example of the radio buttons in the same form; however, this is a pure HTML example and not a PHP example. <form> <input type="radio" name="sex" value="male" /> Male <br /> <input type="radio" name="sex" value="female" /> Female </form> Hi thats great, based on what you said I have created the following code, but still have one more question. <?php /* $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- search //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SEARCH); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'. tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH). '<br>' . tep_hide_session_id() . '<br>'. tep_draw_radio_field('book','search_in_authors_name','1') . ENTRY_AUTHORS_NAME . '<br>'. tep_draw_radio_field('book','search_in_binding','1') . ENTRY_BINDING . '<br>'. tep_draw_radio_field('book','search_in_book_condition','1') . ENTRY_BOOK_CONDITION . '<br>'. tep_draw_radio_field('book','search_in_edition','1') . ENTRY_EDITION . '<br>'. tep_draw_radio_field('book','search_in_publisher','1') . ENTRY_PUBLISHER . '<br>' . tep_draw_radio_field('book','search_in_isbn','1') . ENTRY_ISBN); new infoBox($info_box_contents) ?> </td> </tr> <!-- search_eof //--> this gives me the radio buttons and the ability to selct just any one of the set, however the default set appears to be the last button, how do I make the firs one authors name be selected as default? Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
MrPhil Posted May 10, 2010 Share Posted May 10, 2010 You have the third parameter of tep_draw_radio_field() as '1' in all cases. It should be false, except for the one you want preselected (it should be true). The way you coded it, it interpreted '1' as true, so only the last button marked true was selected. You want to explicitly mark the first button true and all the others false. tep_draw_radio_field('book','search_in_authors_name',true) ... tep_draw_radio_field('book','search_in_binding',false) ... etc. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 11, 2010 Author Share Posted May 11, 2010 You have the third parameter of tep_draw_radio_field() as '1' in all cases. It should be false, except for the one you want preselected (it should be true). The way you coded it, it interpreted '1' as true, so only the last button marked true was selected. You want to explicitly mark the first button true and all the others false. tep_draw_radio_field('book','search_in_authors_name',true) ... tep_draw_radio_field('book','search_in_binding',false) ... etc. Cheers, I had tried true and false, but still had the ones in place, thats done the job thanks. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 Hi, okay so it works, bit rather than having to go and edit the file every time is there a way to create an off switch, so admins configuration I will have. authors_search yes then the radio button for authors name will be bacom e available, but if no then it will not be available to do the search. normally for switches i have used in the past, i would say something like <?php if(AUTHORS_SEARCH == 'on') { search author code}?> where the bit between the {} has the code I want using. but not sure how to incorpoate that with the above tep_draw_radio_field, I am looking for some exaples havent found any yet, but if anyone can help it be appreciated. Thanks Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 Hi, I have the following code:- <?php /* $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- search //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SEARCH); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'. tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH). '<br>' . tep_hide_session_id() . '<br>'.(AUTHORS_SEARCH == 'on').(tep_draw_radio_field('book','search_in_authors_name',true) . ENTRY_AUTHORS_NAME. '<br>') .tep_draw_radio_field('book','search_in_binding',false) . ENTRY_BINDING . '<br>'. tep_draw_radio_field('book','search_in_book_condition',false) . ENTRY_BOOK_CONDITION . '<br>'. tep_draw_radio_field('book','search_in_edition',false) . ENTRY_EDITION . '<br>'. tep_draw_radio_field('book','search_in_publisher',false) . ENTRY_PUBLISHER . '<br>' . tep_draw_radio_field('book','search_in_isbn',false) . ENTRY_ISBN); new infoBox($info_box_contents) ?> </td> </tr> <!-- search_eof //--> as you can see I am trying to apply the switch to the authors name only at the moment, I know that if I switch athors_name on in admin, I get a 1 displyaing in front of the radio button and nothing in front if I have it swicthed off. but what I want is instead of the 1 I want authours name and instead of nothing showing in front of the radio button I want the radio button and suthors name text not displaying. So close but so far away, if I try to use an iff stement I get unexpected if error, can anyone enlighten me on this please. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
MrPhil Posted May 16, 2010 Share Posted May 16, 2010 If you have AUTHORS_SEARCH defined somewhere, the best thing would be to modify the code to add disabled="disabled" on buttons where you want that button disabled (grayed out). tep_draw_radio_field('book','search_in_authors_name',true,(AUTHORS_SEARCH=='on')?'':'disabled="disabled"') ... tep_draw_radio_field('book','search_in_binding',false,(BINDING_SEARCH=='on')?'':'disabled="disabled"') ... Of course, if AUTHORS SEARCH is disabled, you want your default selection (true/false) to be on another button, so you will want some code to do that. Or, you can just default check another button that's never disabled. Incidentally, you would never simply remove an unavailable choice. It is confusing to users to have controls changing their layout at different times. You always disable (gray out) a choice that you don't want users choosing. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 Hi Phil, the greyed out would confuse customers more I think, as they may not understand why its greyed out, and on the store front its a serious issue, whilst book popel may well visit the site more than once, I dont thing a greyed out option looks good or even be understood, most technophobes probably would think its broken. The idea is to make options avilable for a customer to search, but in admin can be selected and optimised for the best things to search on out of a possible 10-15 fields, ideally keeping this to about 4 or 5 would be optimal. For example some older books dont have isbns so if you specialise in old books you probably wouldnt want to search on isbns at all, but if you specialise in modern titles then you would want to use that as a search option. By they way tried it and it works and do think it is better to have it not showing on front page if disabled in admin. Is that possible? Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
MrPhil Posted May 16, 2010 Share Posted May 16, 2010 Trust me, it's considered very bad interface design to have the layout change seemingly randomly. However, if you wish to proceed with not showing choices, it's easy enough: $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'. tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH) . '<br>'); // add enabled buttons $temp = ''; $temp .= tep_hide_session_id(); // ??? not sure where this goes if (AUTHORS_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_authors_name',true) . ENTRY_AUTHORS_NAME. '<br>'; if (BINDING_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_binding',false) . ENTRY_BINDING . '<br>'; if (CONDITION_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_book_condition',false) . ENTRY_BOOK_CONDITION . '<br>'; if (EDITION_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_edition',false) . ENTRY_EDITION . '<br>'; if (PUBLISHER_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_publisher',false) . ENTRY_PUBLISHER . '<br>'; if (ISBN_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_isbn',false) . ENTRY_ISBN . '<br>'; $info_box_contents['text'] .= $temp; new infoBox($info_box_contents) That's probably neater and more understandable (for the programmer) than putting everything "in line" with (test)?in:out tests. Now which one to pre-check (preselect) with true is up to you. It might be the first option displayed, or there might be a hierarchy among the options as to which one to preselect. If you don't preselect any, some browsers may choose the first one for you, others may not choose any. I'm not sure what the defined behavior is if you don't preselect a button. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 Trust me, it's considered very bad interface design to have the layout change seemingly randomly. However, if you wish to proceed with not showing choices, it's easy enough: $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'. tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH) . '<br>'); // add enabled buttons $temp = ''; $temp .= tep_hide_session_id(); // ??? not sure where this goes if (AUTHORS_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_authors_name',true) . ENTRY_AUTHORS_NAME. '<br>'; if (BINDING_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_binding',false) . ENTRY_BINDING . '<br>'; if (CONDITION_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_book_condition',false) . ENTRY_BOOK_CONDITION . '<br>'; if (EDITION_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_edition',false) . ENTRY_EDITION . '<br>'; if (PUBLISHER_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_publisher',false) . ENTRY_PUBLISHER . '<br>'; if (ISBN_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_isbn',false) . ENTRY_ISBN . '<br>'; $info_box_contents['text'] .= $temp; new infoBox($info_box_contents) That's probably neater and more understandable (for the programmer) than putting everything "in line" with (test)?in:out tests. Now which one to pre-check (preselect) with true is up to you. It might be the first option displayed, or there might be a hierarchy among the options as to which one to preselect. If you don't preselect any, some browsers may choose the first one for you, others may not choose any. I'm not sure what the defined behavior is if you don't preselect a button. Hi Phil, thanks for your help, I dont see any errors showing, however I dont have any options either. I have by the looks of it a standard search box. I will have a look and see if I can work it out, basically its just need tp get the options to display now. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 hang on need to check i have defined everything properly brb okay still no joy, having tea then having a nother crack at it thanks for your help Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 Hi, think I have it working bit further tests will tell, the switches are working to make the option available. let us know if there any known issues with my apparent solution. <?php /* $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- search //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SEARCH); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'. tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH) . '<br>'); // add enabled buttons $temp = ''; $temp .= tep_hide_session_id(); // ??? not sure where this goes if (AUTHORS_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_authors_name',true) . ENTRY_AUTHORS_NAME. '<br>'; if (BINDING_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_binding',false) . ENTRY_BINDING . '<br>'; if (CONDITION_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_book_condition',false) . ENTRY_BOOK_CONDITION . '<br>'; if (EDITION_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_edition',false) . ENTRY_EDITION . '<br>'; if (PUBLISHER_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_publisher',false) . ENTRY_PUBLISHER . '<br>'; if (ISBN_SEARCH == 'on') $temp .= tep_draw_radio_field('book','search_in_isbn',false) . ENTRY_ISBN . '<br>'; $info_box_contents[]= array('text' =>$temp); new infoBox($info_box_contents) ?> </td> </tr> <!-- search_eof //--> Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 hmm I am struggling with this, I thought I had things working with repect to searching in particular fields, however it appears not at the moment so taken a step back to tru and find out why the search results arent right. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 oh sometimes I feel like bashing my head against a brick wall. I had at one point the means to to do serches by other fields, or so i though, when i try and go back can i get the thing to work can i hellers like. the quick search box posts the variable to advanced search results i had modified this to work but now i cant get it at all to work. can anyone give my some tips on what i should do to the advanced searxh to get these searchs to work by selection. all fields are in products_description table Thanks, off to cry for A BIT WHILe I TRY AND WORK OUT WHERE I LOST THE PLOT Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
MrPhil Posted May 16, 2010 Share Posted May 16, 2010 Try $info_box_contents[0]['text'] .= $temp; instead. For some reason you're creating an array for info_box_contents, and then putting an array in the first element (resulting in a 1x3 matrix instead of a 3 element array). Maybe that structure is needed for the infoBox constructor? Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 Try $info_box_contents[0]['text'] .= $temp; instead. For some reason you're creating an array for info_box_contents, and then putting an array in the first element (resulting in a 1x3 matrix instead of a 3 element array). Maybe that structure is needed for the infoBox constructor? Hi, the form still doesnt appear to be correct in passing values looks presentable, but its not actually passing the correct information on, the wrong value. As far as I can tell the keywords passes the value entered in the text box, the search_in_autors_name is passing search_in_authors name. so the question is why and how do we correct it, the cheboxes didnt give this issue..hhhhmmmmm Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 16, 2010 Author Share Posted May 16, 2010 hi the following checkbox code works:- <?php /* $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License*/?><!-- search //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SEARCH); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'. tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH). '<br>' . tep_hide_session_id() . '<br>'. tep_draw_checkbox_field('search_in_authors_name') . ENTRY_AUTHORS_NAME . '<br>'. tep_draw_checkbox_field('search_in_binding') . ENTRY_BINDING . '<br>'. tep_draw_checkbox_field('search_in_book_condition') . ENTRY_BOOK_CONDITION . '<br>'. tep_draw_checkbox_field('search_in_edition','1') . ENTRY_EDITION . '<br>'. tep_draw_checkbox_field('search_in_publisher') . ENTRY_PUBLISHER . '<br>' . tep_draw_checkbox_field('search_in_isbn') . ENTRY_ISBN); new infoBox($info_box_contents) ?> </td> </tr> <!-- search_eof //--> but I want radio buttons, and i want to be able to select in admin which options are available to search on. so do I try and get the check boxes to be selectable first and then try and get things working for radio or???? hmmm its bugging me time for bed and make after a docs visit I will be able to crack on with this and get it sorted. have fun. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 17, 2010 Author Share Posted May 17, 2010 Okay played a little more, I can get radio buttons to work with search, but not working when grouped together so that the switches can be selected either or. Checkboxes work, but they dont need to be grouped and you can select one all all of them. When I have the radio buttons grouped, I get the value as (search_in_authors_name) or the corrosponding one for each radio. when ungrouped I have the value as on. on works (search_in_authors_name) doesnt Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 17, 2010 Author Share Posted May 17, 2010 okay so I am thick! the group name is book, so I need to change the results.php to get book instead of search_in_authors_name now that works, back to switching the thins on and off. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 17, 2010 Author Share Posted May 17, 2010 okay the following code is working for searches, but I am strugglin to get the if on code working, it displays and sumbits but doesnt appear its submitting properly. <?php /* $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?><!-- search //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SEARCH); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_QUICK_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>'.tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH). '<br>' . tep_hide_session_id() . '<br>'. tep_draw_radio_field('book','search_in_authors_name','true') . ENTRY_AUTHORS_NAME . '<br>'. tep_draw_radio_field('book','search_in_binding','false') . ENTRY_BINDING . '<br>'. tep_draw_radio_field('book','search_in_book_condition','false') . ENTRY_BOOK_CONDITION . '<br>'. tep_draw_radio_field('book','search_in_edition','false') . ENTRY_EDITION . '<br>'. tep_draw_radio_field('book','search_in_publisher','false') . ENTRY_PUBLISHER . '<br>' . tep_draw_radio_field('book','search_in_isbn','false') . ENTRY_ISBN); new infoBox($info_box_contents) ?> </td> </tr> <!-- search_eof //--> the corrosponding advanced search results file:- <?php /* $Id: advanced_search_result.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH); $error = false; if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) && (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) && (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) && (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) && (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) { $error = true; $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); } else { $dfrom = ''; $dto = ''; $pfrom = ''; $pto = ''; $keywords = ''; if (isset($HTTP_GET_VARS['dfrom'])) { $dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']); } if (isset($HTTP_GET_VARS['dto'])) { $dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']); } if (isset($HTTP_GET_VARS['pfrom'])) { $pfrom = $HTTP_GET_VARS['pfrom']; } if (isset($HTTP_GET_VARS['pto'])) { $pto = $HTTP_GET_VARS['pto']; } if (isset($HTTP_GET_VARS['keywords'])) { $keywords = $HTTP_GET_VARS['keywords']; } $date_check_error = false; if (tep_not_null($dfrom)) { if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) { $error = true; $date_check_error = true; $messageStack->add_session('search', ERROR_INVALID_FROM_DATE); } } if (tep_not_null($dto)) { if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) { $error = true; $date_check_error = true; $messageStack->add_session('search', ERROR_INVALID_TO_DATE); } } if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) { if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) { $error = true; $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE); } } $price_check_error = false; if (tep_not_null($pfrom)) { if (!settype($pfrom, 'double')) { $error = true; $price_check_error = true; $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM); } } if (tep_not_null($pto)) { if (!settype($pto, 'double')) { $error = true; $price_check_error = true; $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM); } } if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) { if ($pfrom >= $pto) { $error = true; $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM); } } if (tep_not_null($keywords)) { if (!tep_parse_search_string($keywords, $search_keywords)) { $error = true; $messageStack->add_session('search', ERROR_INVALID_KEYWORDS); } } } if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) { $error = true; $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); } if ($error == true) { tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false)); } $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH)); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE_2; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td> <?php // create column list $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, pd.products_authors_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price "; if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { $select_str .= ", SUM(tr.tax_rate) as tax_rate "; } $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id"; if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { if (!tep_session_is_registered('customer_country_id')) { $customer_country_id = STORE_COUNTRY; $customer_zone_id = STORE_ZONE; } $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')"; } $from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c"; $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id "; if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) { if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) { $subcategories_array = array(); tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']); $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'"; for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) { $where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'"; } $where_str .= ")"; } else { $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'"; } } if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { $where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"; } if (isset($search_keywords) && (sizeof($search_keywords) > 0)) { $where_str .= " and ("; for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) { switch ($search_keywords[$i]) { case '(': case ')': case 'and': case 'or': $where_str .= " " . $search_keywords[$i] . " "; break; default: $keyword = tep_db_prepare_input($search_keywords[$i]); $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'"; if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'"; if (isset($HTTP_GET_VARS['book'])) $where_str .= " or pd.products_authors_name like '%" . tep_db_input($keyword) . "%'"; if (isset($HTTP_GET_VARS['book'])) $where_str .= " or pd.products_binding like '%" . tep_db_input($keyword) . "%'"; if (isset($HTTP_GET_VARS['book'])) $where_str .= " or pd.products_book_condition like '%" . tep_db_input($keyword) . "%'"; if (isset($HTTP_GET_VARS['book'])) $where_str .= " or pd.products_edition like '%" . tep_db_input($keyword) . "%'"; if (isset($HTTP_GET_VARS['book'])) $where_str .= " or pd.products_isbn like '%" . tep_db_input($keyword) . "%'"; $where_str .= ')'; break; } } $where_str .= " )"; } if (tep_not_null($dfrom)) { $where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'"; } if (tep_not_null($dto)) { $where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'"; } if (tep_not_null($pfrom)) { if ($currencies->is_set($currency)) { $rate = $currencies->get_value($currency); $pfrom = $pfrom / $rate; } } if (tep_not_null($pto)) { if (isset($rate)) { $pto = $pto / $rate; } } if (DISPLAY_PRICE_WITH_TAX == 'true') { if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")"; if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")"; } else { if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")"; if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")"; } if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { $where_str .= " group by p.products_id, tr.tax_priority"; } if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $order_str = ' order by pd.products_name'; break; } } } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); $order_str = ' order by '; switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : ""); break; case 'PRODUCT_LIST_MANUFACTURER': $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $order_str .= "pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; } } $listing_sql = $select_str . $from_str . $where_str . $order_str; require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td> </tr> </table></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> I can certainly say the above works in that the correct information is comming from the correct parts of the database. I am still playing around with the on off function to show/ remove search options but when I was using it the options did display/ not display as desired but the search function didnt actually work. Thanks Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
johnnybebad Posted May 17, 2010 Author Share Posted May 17, 2010 i am going mental one minute its doing what I xpect next its not. Getting better with mods but no programmer am I. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.