PDA

View Full Version : Code Explanation from Tutorial



dcoltonbrown
August 31st, 2004, 11:25 AM
1st of all, thank you to everyone who has helped me in the past. Kirupa is a wonderful resource for people like me who are trying to learn.

I was hoping someone could explain the following code to me.


function displayDetails(c){
textbox.text = c.getSelectedItem().label+" :";
var j = c.getSelectedItem().data;
textbox.text += "\n"+j.getDate()+" "+ month[j.getMonth()]+" "+j.getFullYear();
}


My ultimate goal is to take a selected item in one listbox and send it to another text box to be displayed.

So:

qlist.addItem("a");
qlist.additem("b");
qlist.addItem("c");

//My listbox is named qlist and I want the selected item
//to appear in a text box named player1.
//This is where I am lost because the above sample is pulling
//a date and additional data. Below is my best guess that does not work.
//Can someone please help

function displayDetails(p1){
player1.text = p1.getSelectedItem().label+" :";
}

qlist.setChangeHandler("displayDetails");