【发布时间】:2012-11-29 23:56:58
【问题描述】:
我正在使用 this method 将默认值传递给 Contact Form 7 选择字段。它工作正常,但我真的需要它与无线电场一起工作。
我已尝试将 jquery 更改为:
jQuery(document).ready(function(){
// get contents of hidden input; store in variable
var val = jQuery("span.hiddendefault input").val();
// set the "selected" attribute for option with value equal to variable
jQuery('radio#style-one option[value=' + val + ']').attr('checked', 'checked');
});
和联系表 7:
[radio radio-525 id:style-one class:test-class "one" "two" "three" "four"]
但未按要求检查单选按钮。请问大家有什么想法吗?
[编辑] 表单生成的 html:
<span class="wpcf7-form-control-wrap radio-525">
<span id="style-one" class="wpcf7-form-control wpcf7-radio test-class">
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="one" />
<span class="wpcf7-list-item-label">one</span>
</span>
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="two" />
<span class="wpcf7-list-item-label">two</span>
</span>
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="three" />
<span class="wpcf7-list-item-label">three</span>
</span>
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="four" />
<span class="wpcf7-list-item-label">four</span>
</span>
</span>
</span>
<span class="wpcf7-form-control-wrap hiddendefault">
<input type="hidden" name="hiddendefault" value="three" />
</span>
【问题讨论】:
-
您是否从 url 获取默认值?还是它总是相同的默认值?可以包含表单的 html 吗?
-
我通过一个按钮从 url 传递默认值:
<INPUT TYPE="button" value="i want this design!" onClick="parent.location='order-form?design-no=three'">。请查看表单生成的 html 的已编辑问题。
标签: jquery wordpress contact-form-7