jQuery foldertree issue
<p>I am trying to use the jquery foldertree plugin in a form where the user would click in a input field and a div containing filesystem locations would show up. What I would like to do is capture the value of the folder the users double clicks in the above input field ...</p>

<p>What I have so far:</p>

<p>form code:</p>

<pre><code>...
&lt;input id="input1" type='text' size='30' /&gt;
&lt;div id="smallbrowser" style='z-index: 1; position: absolute; display:none; background: white;'&gt;&lt;/div&gt;
&lt;input type='text' size='30' /&gt;
...
</code></pre>

<p>jquery.foldertree.php</p>

<pre><code>$base = '/location';
if(isset($_REQUEST['dir'])){
    $dir=urldecode($_REQUEST['dir']);
}else{
    $dir='';
}

//sleep(1);

if( file_exists($base.$dir) ) {
    $files = scandir($base.$dir);
    natcasesort($files);
    if( count($files) &gt; 2){ /* The 2 accounts for . and .. */
        echo '&lt;ul class="jqueryFolderTree" style="display: none;" &gt;'; //style="display: none;"
        // All dirs
        foreach($files as $file){
            if( file_exists($base.$dir.$file) &amp;&amp; $file != '.' &amp;&amp; $file != '..' &amp;&amp; is_dir($base.$dir.$file)){
                if(check_for_subdirs($base.$dir.$file)==true){
                    echo '&lt;li&gt;&lt;a href="#" class="collapsed" rel="'.$dir.$file.'/"&gt;&lt;/a&gt;&lt;a href="'.$dir.$file.'/" class="folder"&gt;'.$file.'&lt;/a&gt;&lt;/li&gt;';
                }else{
                    echo '&lt;li&gt;&lt;a href="#" class="nosubs" rel="'.$dir.$file.'/"&gt;&lt;/a&gt;&lt;a href="'.$dir.$file.'/" class="folder"&gt;'.$file.'&lt;/a&gt;&lt;/li&gt;';
                }
            }
        }
        echo '&lt;/ul&gt;';   
    }
}
</code></pre>

<p>and the javascript:</p>

<pre><code>(function($) {
  $.fn.folderTree = function(o) {

      if( !o ) var o = {};
      if( o.root == undefined ) o.root = '/'; //e.g. /root/folder/
      if( o.script == undefined ) o.script = 'jquery.foldertree.php';
      if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';

        return this.each(function() { //Builds the whole tree

                function create_node (dir, target, fol){

                    if($(fol).hasClass("sel")){
                        $(fol).removeClass('folder').addClass('waitb');
                    }else{
                        $(fol).removeClass('folder').addClass('wait');
                    }

                    $.post(o.script, { dir: dir }, function(data) {
                        $(fol).removeClass('wait waitb').addClass('folder');
                        if(dir == o.root){ //if is the root dir
                            data = data;
                            target.html(data);
                            target.find("ul.jqueryFolderTree").show();
                        }else{
                            target.append(data);
                            target.find("ul.jqueryFolderTree").css({'padding-left':'20px'}).show();
                        }
                    });
                }

                $(this).delegate(".collapsed", "click", function(e){
                    $(this).removeClass("collapsed").addClass("expanded");
                    var cur_li = $(this).closest("li");
                    var ul_to = cur_li.find("ul.jqueryFolderTree").first();
                    if(ul_to.length &gt; 0){
                        ul_to.show();
                    }else{
                        create_node($(this).attr('rel'), cur_li, $(this).next('li a.folder') );
                    }
                });


                $(this).delegate(".expanded", "click", function(e){
                    $(this).removeClass("expanded").addClass("collapsed");
                    var cur_li = $(this).closest("li");
                    var ul_to = cur_li.find("ul.jqueryFolderTree").first();
                    ul_to.hide();
                });

                $(this).delegate(".folder", "click", function(e){
                    $(".folder", $(this).attr("id")).removeClass("sel");
                    $(this).addClass("sel");
                    e.preventDefault();
                });

                $(this).delegate(".folder", "dblclick", function(e){
                    $("#input1").val(...?...);
                    $("#smallbrowser").hide();
                });

                $(this).html('&lt;ul class="jqueryFolderTree"&gt;&lt;li class="wait"&gt;' + o.loadMessage + '&lt;/li&gt;&lt;/ul&gt;');
                create_node(o.root, $(this));
        });

  }
})(jQuery);
</code></pre>

<p>I added the code that detects the double click but I don't know what value to capture and insert in the input field.</p>

<p>LE. I guess I should've give it more time because I found the solution:</p>

<pre><code>$(this).delegate(".folder", "dblclick", function(e){
$("#input1").val('/location' + $(this).attr("href"));
$("#smallbrowser").hide();
</code></pre>

<p>I'll leave the question maybe someone else can use it ...</p>
