PDA

View Full Version : Questions about <select> tag


gyhuang33
06-08-2008, 01:58 PM
Hello all
Sorry to bother you again. I have something like this:
<select id="playerList" name="playerList" size="10" style="width: 6cm"></select>
I want to update this part using information from server. I am using ajax.
I used this code in javasrcipt to update it:
document.getElementById("playerList").add(data);

However, it doesnot work.
Also, how to get which "player" is clicked using javascript
Because I am a newbie, I even do not know whether I should use <select> here. Basically, I want to dynamically update a player list, client can choose one player or many players to do some specific task. So, I want to know how to update it and how to select it.

Thanks.

gyhuang33
06-08-2008, 01:59 PM
For example, I want to use the select tag as in this link:
http://www.htmlcodetutorial.com/linking/linking_famsupp_114.html
However, I donot know how to update it online. That means if the choice by select is changing, the select tag should reflect this. Thanks

gyhuang33
06-08-2008, 03:17 PM
this is my code

function updateonlineuser(data){
var target=document.getElementById("playerList");

var y=document.createElement('option');
data=eval(data);
y.text=data;
target.add(y,null); // standards compliant

}

I strictly follow http://www.w3schools.com/htmldom/met_select_add.asp
However, it does not work