开发者

On submit echo td dropdowns and ad new td

开发者 https://www.devze.com 2023-02-26 05:10 出处:网络
I have the following code: <form action=\"\" method=\"POST\"> <?php $count = isset($_POST[\'count\']) ? $_POST[\'count\'] : 1;

I have the following code:

<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" />

How ca开发者_如何学Cn I make the fields into a dropdowns and when you press submit echo out the dropdown as text instead as a dropdown?


First: Fill in the following:

  1. Make this to action="mytestpage.php"
  2. Give this a name attribue like: name="send"
  3. Give these fields types like: type="Text"

If you want a dropdown menu use <select> in combination with <option>...

Here is a start to learn how:
http://www.echoecho.com/htmlforms11.htm

To print your result do this:

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

I hope it helped you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号