首页 > 后端开发 > php教程 > html - 非from表单怎么体检给php?全部代码没有from,用的是suimobile的前端框架

html - 非from表单怎么体检给php?全部代码没有from,用的是suimobile的前端框架

WBOY
发布: 2016-08-04 09:20:42
原创
1076 人浏览过

请问下面的这种非from表单怎么提交给PHP


<code><ul>
  <!-- Text inputs -->
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-name"></i></div>
      <div class="item-inner">
        <div class="item-title label">姓名</div>
        <div class="item-input">
          <input type="text" placeholder="Your name">
        </div>
      </div>
    </div>
  </li>
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-email"></i></div>
      <div class="item-inner">
        <div class="item-title label">邮箱</div>
        <div class="item-input">
          <input type="email" placeholder="E-mail">
        </div>
      </div>
    </div>
  </li>
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-password"></i></div>
      <div class="item-inner">
        <div class="item-title label">密码</div>
        <div class="item-input">
          <input type="password" placeholder="Password" class="">
        </div>
      </div>
    </div>
  </li>
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-gender"></i></div>
      <div class="item-inner">
        <div class="item-title label">性别</div>
        <div class="item-input">
          <select>
            <option>Male</option>
            <option>Female</option>
          </select>
        </div>
      </div>
    </div>
  </li>
  <!-- Date -->
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-calendar"></i></div>
      <div class="item-inner">
        <div class="item-title label">生日</div>
        <div class="item-input">
          <input type="date" placeholder="Birth day" value="2014-04-30">
        </div>
      </div>
    </div>
  </li>
  <!-- Switch (Checkbox) -->
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-toggle"></i></div>
      <div class="item-inner">
        <div class="item-title label">开关</div>
        <div class="item-input">
          <label class="label-switch">
            <input type="checkbox">
            <div class="checkbox"></div>
          </label>
        </div>
      </div>
    </div>
  </li>
  <li class="align-top">
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-comment"></i></div>
      <div class="item-inner">
        <div class="item-title label">文本域</div>
        <div class="item-input">
          <textarea></textarea>
        </div>
      </div>
    </div>
  </li>
</ul></code>
登录后复制
登录后复制


<code><div class="row">
  <div class="col-50"><a href="#" class="button button-big button-fill button-danger">取消</a></div>
  <div class="col-50"><a href="#" class="button button-big button-fill button-success">提交</a></div>
</div></code>
登录后复制
登录后复制


回复内容:

请问下面的这种非from表单怎么提交给PHP


<code><ul>
  <!-- Text inputs -->
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-name"></i></div>
      <div class="item-inner">
        <div class="item-title label">姓名</div>
        <div class="item-input">
          <input type="text" placeholder="Your name">
        </div>
      </div>
    </div>
  </li>
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-email"></i></div>
      <div class="item-inner">
        <div class="item-title label">邮箱</div>
        <div class="item-input">
          <input type="email" placeholder="E-mail">
        </div>
      </div>
    </div>
  </li>
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-password"></i></div>
      <div class="item-inner">
        <div class="item-title label">密码</div>
        <div class="item-input">
          <input type="password" placeholder="Password" class="">
        </div>
      </div>
    </div>
  </li>
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-gender"></i></div>
      <div class="item-inner">
        <div class="item-title label">性别</div>
        <div class="item-input">
          <select>
            <option>Male</option>
            <option>Female</option>
          </select>
        </div>
      </div>
    </div>
  </li>
  <!-- Date -->
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-calendar"></i></div>
      <div class="item-inner">
        <div class="item-title label">生日</div>
        <div class="item-input">
          <input type="date" placeholder="Birth day" value="2014-04-30">
        </div>
      </div>
    </div>
  </li>
  <!-- Switch (Checkbox) -->
  <li>
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-toggle"></i></div>
      <div class="item-inner">
        <div class="item-title label">开关</div>
        <div class="item-input">
          <label class="label-switch">
            <input type="checkbox">
            <div class="checkbox"></div>
          </label>
        </div>
      </div>
    </div>
  </li>
  <li class="align-top">
    <div class="item-content">
      <div class="item-media"><i class="icon icon-form-comment"></i></div>
      <div class="item-inner">
        <div class="item-title label">文本域</div>
        <div class="item-input">
          <textarea></textarea>
        </div>
      </div>
    </div>
  </li>
</ul></code>
登录后复制
登录后复制


<code><div class="row">
  <div class="col-50"><a href="#" class="button button-big button-fill button-danger">取消</a></div>
  <div class="col-50"><a href="#" class="button button-big button-fill button-success">提交</a></div>
</div></code>
登录后复制
登录后复制


如果你不需要跳转可用ajax里的post方法代替表单提交

如果需要跳转 并且是POST提交 可以用CURL

这是我在项目中封装的一个方法 因为需要给远程接口提交数据

<code>//post提交数据
if (! function_exists('postData')) {
    function postData($url, $params)
    {
        $ch = curl_init();
        $timeout = 300;
        $headers = array();
        $headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=utf-8';//设置头文件content-type
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POST, true);//Post请求
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params); //传递参数
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $handles = curl_exec($ch);
        curl_close($ch);
        return $handles;
    }
}</code>
登录后复制

js里面取得各个框的值,然后提交

使用ajax提交就好了

首先是 form 不是 from,另外你需要提交一个不被 form 包含的表单,可以使用 JS 获取要需要提交的值,然后使用 AJAX,假设我们使用 jQuery:

<code class="javascript">$(function() {

    $submitButton = $('.button-success');
    $submitButton.on('click', function() {
        var data = {
            'name1': $('#field1').val(),
            'name2': $('#field2').val(),
            'name3': $('#field3').val()
        };
        $.post('your_url', data);
    });
});</code>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板