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 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的