admin管理员组文章数量:1310012
I am bound to using Contact Form 7 for wordpress. I would like to use a select drop-down, however the available options should not be statically but rather dynamically loaded from the server (to be precise a csv file). I thought about using a filter (something like 'wpcf7_form_tag') but wasn't quite able to make it work yet.
Does anyone have an idea how to tackle that challenge?
I am bound to using Contact Form 7 for wordpress. I would like to use a select drop-down, however the available options should not be statically but rather dynamically loaded from the server (to be precise a csv file). I thought about using a filter (something like 'wpcf7_form_tag') but wasn't quite able to make it work yet.
Does anyone have an idea how to tackle that challenge?
Share Improve this question asked Feb 2 at 8:17 LukiolioLukiolio 93 bronze badges2 Answers
Reset to default 0you can use jQuery for this approach.
$.post("csv.asp", function(data, status){
//split csv with comma
$data = data.split(",");
//empty select - use your page select class
$("select.contact-form-7").html('');
for($i=0;$i<$data.length;$i++){
$option = "<option>"+$data[$i]+"</option>";
$("select.contact-form-7").append($option);
}
});
You can try the Data Source for contact form 7 ( https://wordpress./plugins/cf7-data-source/ ). It includes a pair of additional controls, Recordsed, to get the data from different data sources, like a database, a CSV file, a JSON structure, and other alternatives, and the RecordSet Field Link control that allows you to connect the form fields, like the DropDown field with the RecordSet to populate the first one with the information obtained from the data source.
You can find multiple functional examples in the following link:
https://cf7-datasource.dwbooster/examples
本文标签: phpContact Form 7 select dynamic value from serverStack Overflow
版权声明:本文标题:php - Contact Form 7 select dynamic value from server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741853711a2401220.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论