【问题标题】:contactform 7 autoselect states when click on country点击国家时联系表格 7 自动选择州
【发布时间】:2014-10-30 13:05:53
【问题描述】:

我正在使用联系表格 7,为国家、州选择下拉列表,当我们在第一个选择下拉列表中选择特定国家时,是否可以显示相应的州和城市

【问题讨论】:

  • 可以通过调用 ajax 来填充国家下拉列表更改事件的状态。类似地,您可以填充城市。检查 this 以获取 jQuery ajax。
  • 您的国家/地区选择框和州选择框的 id/class 是什么?
  • 各自的 id 是 "countries", "states"
  • @mevius,谢谢,这不是我需要的。

标签: jquery wordpress contact-form-7


【解决方案1】:

将以下行添加到您的footer.php 或其他地方。为所有STATE 选择框提供相同的类 名称。

var $sub = $('select.states');

$('#countries').first().change(function () {    
    $sub.hide();
    if (this.selectedIndex > 0)
        $sub.eq(this.selectedIndex - 1).show();
}).change();

你也可以为城市做类似的事情。

**注意:**假设 State 选择框具有 states 类名。

【讨论】:

    猜你喜欢
    • 2017-08-27
    • 1970-01-01
    • 2021-11-15
    • 2016-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-15
    • 2018-06-09
    相关资源
    最近更新 更多