[英]How to get the value based on the selected option value
我有以下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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.