ziedinjsh Posted November 6, 2010 Report Share Posted November 6, 2010 php funkcija: function player(){ echo '<div class="song" onclick="snd=new Audio(\'demo/somewhere_is_something_demo.mp3\'); snd.play();"></div>'; } php funkcijas izvade echo "<div class='play'>".player()."</div>"; css: .play{ padding-left:20px; border:1px solid #ACD334; float:left; margin-right:20px; } izvadītā funkcija nav iekš paradzētā div, kapēc tā? Quote Link to comment Share on other sites More sharing options...
No0ne Posted November 6, 2010 Report Share Posted November 6, 2010 vai tik vina nav ieks `song` div? Quote Link to comment Share on other sites More sharing options...
codez Posted November 6, 2010 Report Share Posted November 6, 2010 (edited) Tāpēc, ka brīdi, kad izsauc funkciju, fukcija izpilda echo, kamēr vietā, kur tu izsauc funkciju, tev vajag, lai funkcija atgriež string-u: vajag tā: function player(){ return '<div class="song" onclick="snd=new Audio(\'demo/somewhere_is_something_demo.mp3\'); snd.play();"></div>'; } Un, lai varētu likt dažādas dziesmas, vajag izmantot funkcijas parametrus: function player($filename){ return '<div class="song" onclick="snd=new Audio(\''.$filename.'\'); snd.play();"></div>'; } Edited November 6, 2010 by codez Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted November 6, 2010 Author Report Share Posted November 6, 2010 Paldies par palīdzību! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.