日期:2014-05-20  浏览次数:20564 次

jsp 关联歌词
知道选择下拉框的index,如何播放相应的歌词,即知道javascript中的列表的选中的index,如何让jsp知道这个index,是不是要用Ajax

<script language="javascript">
function PlayMusic() //下一曲
{
  var player = document.getElementById("MediaPlayerObject");
  var index = PlayListSelect.selectedIndex + 1;
  if (index > PlayListSelect.options.length -1)
  {
  index = 0;
  }
  PlayListSelect.selectedIndex = index; //这里知道选 中的index是多少
  player.URL = PlayListSelect.options[index].value;
  //alert(player.URL);
  player.controls.play();
}
</script>
  <textarea cols="20" rows="10" name="lyric">
  <!--这里怎么取到-->
  </textarea>

  ---连播列表---
  <select multiple="multiple" id="PlayListSelect">
  <%
  for(int i=0;i<mylist.size();i++)
  {
  music=(Music)mylist.get(i);
  %>
  <option value="<%=new String(music.getUrl().getBytes("iso-8859-1"),"GB2312") %>">
  <%=new String(music.getName().getBytes("iso-8859-1"),"GB2312") %></option>
  <%
  }
  }
  %>
  </select>
 <button onclick="PlayLast()">上一曲</button>
 <button onclick="PlayMusic()">下一曲</button>  


------解决方案--------------------
歌词在数据库里?如果不想刷新页面用ajax传值吧~,service里处理一下

struts 2.0
如果传过来的直接是歌词
<s:property value="" >

如果是在service里传过来的是jsp代码

<s:property escape="false"/>


struts 1.0

<bean:write name="lyric">
------解决方案--------------------
up