28.json数组,select选择,input输出对应数据

效果:选择对应的车类,下面的input会实时出现车价。

html:

<form action="" class="priceModelform1">
<!-- select选择  motorcycle1 -->
<select class="motorcycle1" name="motorcycle1" id="motorcycle1" onchange="motorcycleChange1()" >
<option value="">请选择</option>
<option value="0">汽车</option>
<option value="3">轿车</option>
</select>
<!-- input输出数据  purchase1 -->
<input class="purchase1" type="number" readonly="readonly" value="">

</form>

js:

var cartConfig={
"0":{"purchaseMoney":10},
"3":{"purchaseMoney":7.5}};
function motorcycleChange1(){
var motorcycle1= $("#motorcycle1 option:selected").val();
//console.log(motorcycle1);
var a= $(".purchase1").val(cartConfig[motorcycle1].purchaseMoney);
//console.log(a);
}

原文地址:https://www.cnblogs.com/sqyambition/p/8503494.html

时间: 2024-08-09 12:56:53

28.json数组,select选择,input输出对应数据的相关文章

Vue-切割json数组字符串并循环输出

Json "detailList":[ " 04/08/2016 - LA - - Dept. - TITLE (Lien Reported)", " 04/05/2016 - KA - - Motor Dept. - REGISTRATION RENEWAL (Lease) ", " 03/20/2016 - SA - 30 - Motor Dept. - ODOMETER", " 03/16/2016 - - -

php输出json数组和json

function getCitys(){ $provinceid=trim($_REQUEST['province']); $citylist=M('city')->field('cityid,cityname')->where('provinceid ='.$provinceid)->select();         //这个方法输出json数组 //echo json_encode($citylist); $temp='{'; for ($i=0;$i<count($city

select绑定json数组对象 asp.net

ashx处理页 string JsonList = "["; IList<Models.Channel> ilist = BLL.ChannelManager.GetAllChannels(); List<Models.Channel> list = PublicCS.IListToList(ilist);/// IList转化为List JsonList += "{id:0,ChannelName:'顶级栏目'},"; foreach (M

ajax请求base64加密后的json数组,并通过vue的v-for遍历输出

$.ajax({ type: 'get', dataType: 'json', url: '/Template/xpshop_currents/inc/imgUrl.json', cache: false, success: function (data) { //window.atob()base64解码,escape编码,decodeURIComponent解码,这里是为了解决base64解码后的中文乱码问题 let spdata = decodeURIComponent(escape(wi

jQuery获取Select选择的Text(非表单元素)和 Value(表单元素)(转)

jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发 2. var checkText=$("#select_id").find("option:selected").text(); //获取Select选择的Text 3. var checkValue=$("#selec

jQuery获取Select选择的Text和 Value

jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...});   //为Select添加事件,当选择其中一项时触发 2. var checkText=$("#select_id").find("option:selected").text();  //获取Select选择的Text 3. var checkValue=$("#se

jQuery获取Select选择的Text和 Value(转)

jQuery获取Select选择的Text和Value:语法解释:1. $("#select_id").change(function(){//code...});   //为Select添加事件,当选择其中一项时触发2. var checkText=$("#select_id").find("option:selected").text();  //获取Select选择的Text3. var checkValue=$("#select

jQuery获取Select选择的Text和Value[转载]

语法解释:1. $("#select_id").change(function(){//code...});   //为Select添加事件,当选择其中一项时触发2. var checkText=$("#select_id").find("option:selected").text();  //获取Select选择的Text3. var checkValue=$("#select_id").val();  //获取Selec

Springboot+ajax传输json数组以及单条数据的方法

Springboot+ajax传输json数组以及单条数据的方法 下面是用ajax传输到后台单条以及多条数据的解析的Demo: 结构图如下: 下面是相关的代码: pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20