Set a selected value for my dropdown list
Results 1 to 5 of 5

Thread: Set a selected value for my dropdown list

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    23

    Set a selected value for my dropdown list

    Ok hope I clarify things here and any help is appreciated

    PHP Code:

    function ShowPage($size) {

    /* init next and previous link class. Set a default page size of 40 */

      
    if (empty($size)) { $size "40"; }
      if (empty(
    $pg_which)) { $pg_which=1; }
      
    $nav = new navigator;
      
    $nav->pg_size $size;
      
    $nav->cp_size $max_pages;
      
    $nav->cp_more $max_chapters;
      
    $nav->href "browse.php";
      
    $nav->more_param "&cat=$cat";

      
    $nav->pg_which=$pg_which;
      
    $nav->rec_count=$num_rows;
      
    $nav->init(); 

     
    /* Generate a dropdown list menu */
      
    $record "<select name=menu1 onChange=\"MM_jumpMenu('self',this,0)\">\n";
      for(
    $records 10$records <= 100$records += 10) {
        if (
    $records == $size) { $sel ' selected'; }
        
    $record .= "<option value=\"browse.php?cat=$cat&size=" $records "\"" $sel ">" $records " Results</option>\n";
      }
      
    $record .= "</select>\n";
      
    $pagination $nav->print_all(); 
    I've already set a default value of 40 results to be shown so I have to make the dropdown to select on 40, but the results in html source goes like this:

    PHP Code:

    <select name=menu1 onChange="MM_jumpMenu('self',this,0)">
    <
    option value="browse.php?cat=476&size=10">10 Results</option>
    <
    option value="browse.php?cat=476&size=20">20 Results</option>
    <
    option value="browse.php?cat=476&size=30">30 Results</option>
    <
    option value="browse.php?cat=476&size=40" selected>40 Results</option>
    <
    option value="browse.php?cat=476&size=50" selected>50 Results</option>
    <
    option value="browse.php?cat=476&size=60" selected>60 Results</option>
    <
    option value="browse.php?cat=476&size=70" selected>70 Results</option>
    <
    option value="browse.php?cat=476&size=80" selected>80 Results</option>
    <
    option value="browse.php?cat=476&size=90" selected>90 Results</option>
    <
    option value="browse.php?cat=476&size=100" selected>100 Results</option>
    </
    select
    Any ideas?

  2. #2
    & depreciated brøken's Avatar
    Join Date
    Sep 2002
    Location
    nj
    Posts
    229
    i dont see anything really wrong, but rty changing

    PHP Code:
    // this:
    if ($records == $size) { $sel ' selected'; }

    // to this:

    $sel=(($records==$size)?" selected":""); 
    bc as far as i know, once it hits 40, the $sel = "selected" and its never un-defined, so as it loops through, $sel still = selected..


    hope thats clear
    $drink->heineken();

  3. #3
    Junior Member
    Join Date
    Sep 2002
    Posts
    23
    no dice. Still the same. I'm going crazy...

  4. #4
    Junior Member
    Join Date
    Sep 2002
    Posts
    23
    oh it works! I've misplaced your code!!! Oh my, thanks alot and a million! Broken!!!

  5. #5
    & depreciated brøken's Avatar
    Join Date
    Sep 2002
    Location
    nj
    Posts
    229
    n/p, im always writing that code, so i know how annoying it can get
    $drink->heineken();

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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