2011-04-18 67 views
-1

我有以下代碼:在提交呼應TD下拉菜單和廣告新的TD

<form action="" method="POST"> 
<?php 
$count = isset($_POST['count']) ? $_POST['count'] : 1; 
if($count > 11) $count = 11; 
?> 

<table> 
<!-- Keeps track of the current number of rows --> 
<input type="hidden" name="count" value="<?php echo $count+1; ?>"/> 

<?php for($i = 0; $i < $count; $i++): 
// Loop through all rows gathering the data here, and then creating the fields below 

$val0 = isset($_POST['field'][$i]['0']) ? $_POST['field'][$i]['0'] : ''; 
$val1 = isset($_POST['field'][$i]['1']) ? $_POST['field'][$i]['1'] : ''; 
$val2 = isset($_POST['field'][$i]['2']) ? $_POST['field'][$i]['2'] : ''; 
?> 
<tr> 

<td><input name="field[<?php echo $i; ?>][0]" value="<?php echo $val0; ?>"/></td> 
<td><input name="field[<?php echo $i; ?>][1]" value="<?php echo $val1; ?>"/></td> 
<td><input name="field[<?php echo $i; ?>][2]" value="<?php echo $val2; ?>"/></td> 
</tr> 
<?php endfor; ?> 

</table> 

<input type="submit" value="click me" /> 

我怎樣才能使字段爲下拉列表,當你按下提交回聲出下拉的文本,而不是作爲一個下拉列表?

+0

用戶的其他問題的精確欺騙:http://stackoverflow.com/questions/5702863/php-on-submit-echo-td-fields-and-ad-new-td – 2011-04-18 18:59:54

+0

可能重複[Php:on submit回聲td字段和廣告新td](https://stackoverflow.com/questions/5702863/php-on-submit-echo-td-fields-and-ad-new-td) – 2017-07-16 08:36:37

回答

0

第一:填寫下列資料:

  1. 使這個行動= 「mytestpage.php」
  2. 給這名attribue,如:名稱= 「發送」
  3. 給這些字段類型,如:類型= 「文本」

如果你想有一個下拉菜單與<option>組合使用<select> ...

這裏是學習如何開始:
http://www.echoecho.com/htmlforms11.htm

要打印你的結果做到這一點:

if(isset($_POST['send']) 
{ 
    print($_POST['youroptionname']); 
} 

我希望它幫你。

+0

你認爲你可以把它放入我的代碼?我知道如何做下拉和打印我只是不知道該把它放在哪裏? – Slindoncc 2011-04-18 15:02:12

+0

我不能在你的代碼中放入任何東西,你應該這樣做。如果你把你的代碼中的if(isset($ ...)部分放在

的外面,那麼它應該可以工作,只要確保所有的名字都是正確的。 – Mixxiphoid 2011-04-18 15:06:52