求js代码:点击提交按钮,将文本框中的字符赋值给某一个函数

界面如类似百度搜索这样:左边是一个文本框,点击“提交”,就能将文本框中,比如写的是 :“荷塘月色”,则将“荷塘月色”赋值给下面代码中的music这个函数,这样就播放荷塘月色这首歌了。代码:<EMBED src=..DJ/"+music+".mp3 width=0 height=0 border=0 autostart=ture loop=ture >"

<form onsubmit="document.getElementById('playsong').src=document.getElementById('song').value">
<input type="text" name="song" id="song">
<input type="submit" name="submit">
</form>
<EMBED id="playsong" src="" width=0 height=0 border=0 autostart=ture loop=ture >追问

<EMBED id="playsong" src="" 不行啊,难道不得添加路径么

追答

歌曲的存放路径是什么?就是和程序相对的路径。

追问

放在在一个文件夹下,有indexl这个文件,然后又有一个文件夹名是DJ,歌曲就放在这个dj文件夹中,你帮我改一下

追答



温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-11
<body>
<EMBED id="player" src="" width=0 height=0 border=0 autostart=ture loop=ture>
<input type="text" name="txt" id="txt" value="">
<input type="button" onclick="javascript:document.getElementById('player').src='..DJ/'+document.getElementById('txt')+'.mp3';" value="提交">
</body>
相似回答