The problem I would like help solving is once a drop down value on contact form 7 has been selected for example "1" the input box next to it inserts a price in this example "1" should display "£11.99"

Full example as following

1 = £11.99 2 = £13.99 3 = £14.99 (anything above 3 will equal £14.99 up to 12)

Payslips Required
[select* payslips-required "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"]
[text price]

Above is what I currently have. The only close thing I have come across is this. http://jsfiddle.net/erwin21/A8Nxp/246/

Also how would I use the above in conjunction with contact form 7 on Wordpress

Any help would be appreciated.

EDIT

This is how the short code appears in HTML

<script type="text/javascript" src="http://localhost/payslips/wp-content/themes/discover/js/jquery-1.5.2.js"></script>
<script type="text/javascript" src="http://localhost/payslips/wp-content/themes/discover/js/payslipprice.js"></script>

<span class="wpcf7-form-control-wrap payslips-required">
<select name="payslips-required" class="wpcf7-form-control wpcf7-select wpcf7-   validates-as-required" id="payslips-required" aria-required="true">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</span>  

<span class="wpcf7-form-control-wrap price">
<input type="text" name="price" value="" size="40" class="wpcf7-form-control wpcf7 text" id="price" />
</span>
有帮助吗?

解决方案

Updated to work with your example: http://jsfiddle.net/rgin/A8Nxp/353/

var map = [ '£11.99', '£13.99', '£14.99' ];

$('#choice').change(function(){
    var o = parseInt($(this).val()) < 3 ? $(this).val()-1 : 2;
    $('#other').val(map[o]).addClass('hidden');
});


You mean something like this? http://jsfiddle.net/rgin/A8Nxp/352/

$('#choice').change(function(){
    var selected_item = $(":selected", this).text()
    selected_item = parseInt(selected_item) < 3 ? selected_item : '4 and above';
    $('#other').val(selected_item).addClass('hidden');
});

其他提示

try this:

i just edited you fiddle and added some.

var price = ["£11.99","£2.99","£11.99"];    

$('#choice').change(function(){
        $('#other').val(price[parseInt($(this).val())-1]);
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top