dongwo2222 2019-06-14 09:48
浏览 291
已采纳

表格中的Foreach循环

I'm using wordpress to create a website and I need to create a form that allows users to select a number from a dropdown list and then populate the form with that amount of data

Since I'm new with wordpress I'm using the Caldera Forms plugin to build the forms but there's no repeater or something similar to use

I'm not any good with php to create a script for this and can't find any other solution online

IF I Select 3 from the dropdown the following needs to display on the form


Sample 1 Date:[Current Date]
Code:[text]
Flock:[text]
Species:[text]
Age (days):[text]
House:[text]
Analysis Required:[text]

SAMPLE 2

Sample 2 Date:[Current Date]
Code:[text]
Flock:[text]
Species:[text]
Age (days):[text]
House:[text]
Analysis Required)[text]

SAMPLE 3

Sample 3 Date:[Current Date]
Code:[text]
Flock:[text]
Species:[text]
Age (days):[text]
House:[text]
Analysis Required:[text]```

edit: Caldera forms has a Conditional tab that allows you to add if statements 
  • 写回答

1条回答 默认 最新

  • dprc88435 2019-06-14 13:15
    关注

    So, if you decide to do without plugin, this is part for front end, to add remove and submit samples https://jsfiddle.net/Beneris/ns7dq9Lz/39/

    You still need to add ajax_url to footer.php

    <script>var ajax_url = "<?php echo admin_url( 'admin-ajax.php' ); ?>";</script>
    

    And function to process submitted data, to functions.php

    add_action( 'wp_ajax_save_samples', 'ajax_save_samples' );
    add_action( 'wp_ajax_nopriv_save_samples', 'ajax_save_samples' );
    
    function ajax_save_samples() {
        $json= strip_tags($_POST['json']);
        $data = json_decode($json);
        foreach ($data as $d) {}
        exit;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料