SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    Cornwall, UK
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Dynamic select box problem

    I've got a couple of functions to produce a form and it's all working fine but I want the select box to pick up a value and have that option selected. I can't see the fatal flaw in my coding though!

    Code:
     function selected($var1, $var2) 
    {
    if ($var1==$var2)
    {
    return "selected";
    }
    }
    Code:
     function optSelect($selector) 
    {
    $select="<option value=\"t\" selected=\"".$this->selected("t",$selector)."\">yes</option>";
    $select.="<option value=\"f\" selected=\"".$this->selected("f",$selector)."\">yes</option>";
    return $select;
    }
    finally my form.

    Code:
     ... 
    <label>Active:</label><select name=\"cactive\">".$this->optSelect("t")."</select> 
    ....
    It should pick up "t" as being the correct value and make that selected however it seems to make both selected and shows the "f" value in the box.

    Can anyone help?

    Many thanks,
    Alix
    Last edited by Alix23; Jul 9, 2006 at 06:53.


Bookmarks

Posting Permissions

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