如何根据所选选项值获取值



我有以下 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
(
)
)
)

如果我选择一个产品名称,它不会显示产品的相应价格值。请提出任何解决方案。

首先更改

<option value="$key['name']">$key['name']</option>

<option value="{{ $key['name'] }}"> {{ $key['name'] }} </option>

按如下方式使用 jquery:

$("#ss1 option:selected").val();

相关内容

  • 没有找到相关文章

最新更新