$(window).load(function(){
        $(".products td").each(/*Wrap existing text in span, like Sam Collet's. 
*/)
        .hover(function(e){
                MakeMe(this);
        },function(e){
                DestroyMe(this);
        })
})

function DestroyMe(element)
{
        $("#active").remove();
        var txt = document.createTextNode( $(find("[EMAIL PROTECTED]")).val() );
        element.appendChild(txt);
}

function MakeMe(element)
{
        //Get the current cellIndex and the select options (split by '//')
        var cellno = element.cellIndex;
        var options = $("p#infobox").html();
        options = options.split("//");

        try
        {
                //Try and split the individual cell for that row (by ',')
                var indoptions = options[cellno].split(",");
        }
        catch(err)
        {
                //Fail... indoptions is blank
                var indoptions = "";
        }
        //If the length of indoptions (as an array) is greater than one...
        if (indoptions.length >1)
        {
          //Create a select box
                var slc = document.createElement("select");
                var attr = docuemnt.createAttribute("id");
                attr.value = "active";
                slc.setAttributeNode(attr);

                $(element).append(slc).find("select").each(function() {
                 //For each option value in the array
                                for (i=0; i<indoptions.length;i++)
                                {
                                  //Create an option and give it its info, then 
append it to the td.
                                        var optioni = 
document.createElement("option");
                                        //optioni.name = "selectbox";
                                        
                                        var attr = 
docuemnt.createAttribute("value");
                                        attr.value = indoptions[i];
                                        optioni.setAttributeNode(attr);
                                        var txt = document.createTextNode =  
indoptions[i];
                                        
                                        optioni.appendChild(txt);
                                        this.appendChild(optioni);
                                }
                })
        }
        else
        {
          //It's not supposed to be a select box. Create a textbox
          //Doesn't work... Work in progress! ;)
                $(this).append(document.createElement("textarea"));
                $(this).innerHTML = 
this.parentNode.previousSibling.firstChild.nodeValue;
        }
}

I did not test this code so it may need to be tweaked, but I think it is
closer to what you need.
-- 
View this message in context: 
http://www.nabble.com/Determine-which-table-column-was-clicked-tf2064756.html#a5706551
Sent from the JQuery forum at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to