动态添加/删除文本框并发布到php

时间:2012-10-06 19:31:36

标签: php javascript jquery html

我是否可以获得添加/删除动态文本框的骨架,然后发布附加的结果。

我希望它看起来像这样:

  

[空文本框] [添加按钮]

将Value1放入文本框并点击添加后,它将显示:

  

[空文本框] [添加按钮]
  [Value1] [删除按钮]

一旦添加了所有内容,我希望它被发布,并允许人们删除任何添加的文本框。

我一直在寻找例子,找不到这样的方法。

<form method="post" id="multi" action="process.php">

   <label for="cname">Company Name: <span class="required">*</span></label>
   <input type="text" size="30px" id="cname" name="cname" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['cname'] : '' ?>" placeholder="The Rainbow Kingdom" required autofocus />

   <label for="name">Contact Name: <span class="required">*</span></label>
   <input type="text" size="30px"id="name" name="name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?>" placeholder="John Doe" required autofocus />

   <label for="email">Email Address: <span class="required">*</span></label>
   <input type="email" size="50px" id="email" name="email" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?>" placeholder="johndoe@example.com" required />

   <label for="telephone">Telephone: </label>                   
   <input size="9px" placeholder="1112223333" autofocus maxlength="9" type="tel" id="telephone" name="telephone" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '' ?>" />         
   <div>
      <label>Tag</label><input class="tag" type="text" name="" type="text" />
      <div id="content" ></div>
   </div>

   <label for="message">Message: <span class="required">*</span></label>
   <textarea id="message" name="message" placeholder="Your message must be greater than 20 characters" required data-minlength="20"><?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '' ?></textarea>

   <p id="req-field-desc">
      <span class="required">*</span> indicates a required field
   </p>
   <span id="loading"></span>

   <input type="submit" value="Submit!" id="submit-button" />
</form>

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

You can take a look at this。相当丑陋但仍然可读。足以让你知道。
该值将显示为普通文本,并将存储在具有类似数组名称的隐藏字段中 提交表单时,将收集隐藏字段中的数据。