我有以下php代码,并从whmcs获取api数据。该代码返回产品名称值。
<select id="ssl" class="form-control select_plan" style="width:95%">
<option value="--Select--">--Select--</option>
@foreach($products['products']['product'] as $key)
@if($key['gid'] == '10')
<option value="{{$key['name']}}">{{$key['name']}}</option>
@endif
@endforeach
</select>
此代码返回产品价格值
@foreach($products['products']['product'] as $key)
@if($key['gid'] == '10')
@foreach($key['pricing'] as $value)
@if($key['name']=='Positive SSL Wildcard')
{{$value['annually']}}
@endif
@endforeach
@endif
@endforeach
这里提到了我来自whmcs的回复数据。请找到数据并提出解决方案
Array
(
[pid] => 31
[gid] => 10
[type] => hostingaccount
[name] => Comodo PositiveSSL
[description] =>
Domain Validation
1 Domain
Free additional server licenses
Issued within 2 days
[module] => GGSSLWHMCS
[paytype] => recurring
[pricing] => Array
(
[INR] => Array
(
[prefix] => ₹
[suffix] => INR
[msetupfee] => 0.00
[qsetupfee] => 0.00
[ssetupfee] => 0.00
[asetupfee] => 0.00
[bsetupfee] => 0.00
[tsetupfee] => 0.00
[monthly] => -1.00
[quarterly] => -1.00
[semiannually] => -1.00
[annually] => 100.00
[biennially] => 200.00
[triennially] => -1.00
)
)
[customfields] => Array
(
[customfield] => Array
(
)
)
[configoptions] => Array
(
[configoption] => Array
(
)
)
)
如果我选择一个产品名称,则不会显示该产品的相应价格值。请提出任何解决方案。
答案 0 :(得分:0)
首先更改
<option value="$key['name']">$key['name']</option>
到
<option value="{{ $key['name'] }}"> {{ $key['name'] }} </option>
答案 1 :(得分:0)
按以下方式使用jquery:
$("#ss1 option:selected").val();