douwen9343 2019-06-23 16:06
浏览 49

将整个Excel行复制到表单域中

I got Excel with 4 columns: Complete name, celphone, city, and comments. And I have HTML/PHP form to send ADF format email.

At the moment I'm copying each cell and paste in each form field. How I can improve my code to copy a row from Excel and paste it in 1 time on my form fields?

I mean I need to detect /n to change form field or something like that? This is part of my actually form

<div class="col-sm-3">
  <div class="form-group">
    <label for="customer_contact_prospect" class="control-label">Nombre completo del prospecto <strong class="text-danger">*</strong></label>
    <input type="text" id="customer_contact_prospect" name="customer_contact_prospect" class="form-control required">
  </div>
</div>

</div>
  • 写回答

1条回答 默认 最新

  • doushan1157 2019-06-23 19:09
    关注

    You can copy and paste a range of data from excel into a text area. The information you've given is insufficient to be used in a mailer, but here's how to extract the excel information:

    HTML Form input:

    <textarea name="excel_info"></textarea>
    

    Receiving PHP script:

    <?php
    $raw_data = $_POST['excel_info'];
    $name = array();
    
    $rows = explode("
    ", $raw_data);
    foreach($rows as $row) {
        $column = explode("\t", $row);
        $name[] = $column[0];
    }
    
    // iterate through $name array and do whatever you need with the names
    // note: no data cleansing has been done; you are responsible for cleaning your own data.
    

    If you're wanting to grab a specific column using javascript, an example using the jquery library for javascript:

    var temp = ('#customer_contact_prospect').val().split("\t");
    var name = temp[0];  // assuming name is the first column
    
    // optionally put it in a hidden input id="name"
    $('#name').val(name);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序