I have select option where i select type of inputs, and i want to show different type of inputs based on selected option.
Example
- select
input-> show input fields - select
textarea-> show text areas - select
bolean-> show radio buttons
Code
Here is where i select my input types,
Notice: @change="inputType"
<div v-for="(index, a) in variationParents" :key="a">
<el-input placeholder="Please input your variation name" v-model="index.name" class="input-with-select">
<el-select @change="inputType" v-model="index.type" slot="prepend" placeholder="Select">
<el-option label="Text" value="input"></el-option>
<el-option label="Text Area" value="textarea"></el-option>
<el-option label="Boolean" value="boolean"></el-option>
</el-select>
</el-input>
</div>
Script
Note: I am aware that i am using jQuery instead of vueJs in this function but it was only to test and make sure that i'm getting the right value out of my select options.
methods: {
inputType: function(value) {
$('.show').html('')
if(value == 'input') {
$('.show').html(value)
} else if(value == 'textarea') {
$('.show').html(value)
} else if(value == 'boolean') {
$('.show').html(value)
}
},
}
HTML
This is where different type of inputs has to be returned, currently it has static input field only, somehow it should be related to function if statements and print related type of inputs
<div class="show"></div> // this DIV was only to test my function values
<el-col :span="9" style="margin-top:15px;display:none;">
<div v-for="(indexx, b) in variationChilds" :key="b">
<!-- child's -->
<el-input v-model="indexx.name" placeholder="Please input your variation value" class="input-with-select">
<el-button slot="append" @click="addChild(b)" type="success" icon="el-icon-plus"></el-button>
<el-button slot="append" @click="removeChild(b)" v-show="b || ( !b == variationChilds.lenghth > 1)" type="danger" icon="el-icon-delete"></el-button>
</el-input>
</div>
</el-col>
ideas?
