我在尋找一種可能性,用一個按鈕代替低輸入文本字段:<input type="button" class="button" name="search" value="Urban" onclick="">
。通過HTML按鈕發佈搜索值
HTML代碼:
<form method="post" action="search.php" id="search_form">
<input type="text" name="search" value="<?php echo $_POST['search']; ?>" class="search_sounds"/>
<input type="submit" value="" class="submit" />
</form>
整個腳本應該搜索數據庫的聲音:
PHP代碼:
<?php if(isset($_POST['search']) && !empty($_POST['search']))
{
include('searchfunction.php');
if(count($data) > 0)
{
?>
<script type="text/javascript">
$(document).ready(function(){
var description = '';
var myPlaylist = [
<?php
echo(implode(',', $data));
?>
];
$('#main').ttwMusicPlayer(myPlaylist, {
autoPlay:false,
description:description, }
);
});
</script>
<?php
}
else
{
echo ('No sounds found.');
}
}
?>
在什麼情況下你要替換一個按鈕上的文本輸入? – Maurice 2012-03-25 13:26:31
我只是想用按鈕替換文本輸入字段。 – 2012-03-25 13:28:12