Results 1 to 2 of 2

Thread: Adding a drop down select field

  1. #1
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default Adding a drop down select field

    I decided to play around with the free verion of indexu before buying the real thing just to make sure it would do what I needed.

    So here is a hack to the power search routine of the lite version ( May 2002 ) to add the ability to find or include those links that are editor picks. I just wanted to see how easy it was. and it was pretty easy. Especially, since my knowledge of PHP is limited to how to spell it and my knowledge of mySQL is only a tad more.

    Anyway, here it is.

    change

    global $cat,$title,$url,$category,$description, $contact_name, $email;
    to

    global $cat,$title,$url,$category,$description, $contact_name, $email, $pick;
    underneath the line above, add:

    $pick= ShowDropDown ("pick","---,Yes,No","2,1,0","");
    Notes:
    $pick is the name of the variable in this function as declared in the global variables

    pick is the name of the form variable in the html page
    "---,Yes,No" are the possible choices as shown to the user when viewing the html page

    "2,1,0" are the actual values to be passed to the database.

    the final "" is the default value of the select statement as presented to the user viewing the html page. By using a "1" the pick box would default to "Yes" when viewed by the user. A zero ( 0 ) would cause the select statement to default to No and "2" would cause it to default to "---". Actually, I believe anything that did not match any of the choices would cause it to default to "---".

    You will need to change

    DisplayTemplate($template_path."power_search_form. html",
    "\$error_msg,\$title,\$url,\$category,\$descriptio n,\$contact_name,\$email");
    to the following

    DisplayTemplate($template_path."power_search_form. html",
    "\$error_msg,\$title,\$url,\$category,\$descriptio n,\$contact_name,\$email, \$pick");
    somewhere under

    $query = "select * from link where 0=0 ";
    add
    if($pick==1) {
    $query .= "and f_pick = 1 ";
    }
    elseif ($pick==0) {$query .= "and f_pick = 0 ";}
    Note: I don't think there is a real need to test for $pick==2 since that means f_pick is not to be part of the query.

    Finally, in the power_search_form.html file add
    <tr>
    <td><font face="Arial" size="2">Pick</font></td>
    <td><%pick%></td>
    </tr>
    after the row for the email row and before the submit button.

    Sorry about the above quote but vBulletin wants to recogize the row and cell tags.
    Last edited by esm; 05-22-2003 at 01:02 PM.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  2. #2
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    I made some changes to make this work better
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Similar Threads

  1. Using Radio Button and Drop Down Menu in Custom Field
    By dody in forum Tutorials, Hints & Tips
    Replies: 2
    Last Post: 12-20-2003, 10:58 PM
  2. Replies: 2
    Last Post: 08-05-2003, 02:16 AM
  3. Adding a Custom Field
    By craven in forum v5.x
    Replies: 1
    Last Post: 07-01-2002, 08:49 AM
  4. Adding custom Field with pictures
    By TheLobo in forum v5.x
    Replies: 0
    Last Post: 10-04-2001, 10:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •