How to Reset Select Drop down in VueJs - vue.js

I am new in vue js please help.
I have two dropdowns and that that dropdown create from loop
<select v-if="tour.city_expert == 2" v-model="selected[index]" class="form-control" :id="'city_expert_both'+index" v-on:change="intiTourCityExpert(index, $event)" :disabled="tour.is_disable==true">
<option value="" selected>Select City Expert</option>
<option value="Guideinperson">Guide in person</option>
<option value="AudioGuide">Audio Guide</option>
</select>
I as per image I want reset dropdown if I uncheck the checkbox but only reset single row as I uncheck the checkbox.
I set v-model="selected[index]" on dropdown and set code on uncheck this.$set(this.selected, index, ''); but its not working.
Help

I ran into similar situation, and following worked for me.
And to rest try following anywhere - this.selectedStatus = '0';
<select id="item_status" class="form-control" v-model="selectedStatus">
<option value='0'></option>
<option value='1'>One</option>
<option value='2'>Two</option>
</select>

If I were you, I would do something like this:
Add an onchange event to the checkbox with its index:
#change="onChange(index)"
In the methods object define the function
onChange like this:
methods: {
onChange(index) {
this.selected[index] = ''
}
}

If you want to reset the value of dropdown on click on any other button or so, than just set it to null.
this.accountType = null;
My Dropdown:
<ejs-dropdownlist
v-model:value="accountType"
:dataSource="accountTypesData"
:select="accountTypeSelect"
placeholder="Select a type"
></ejs-dropdownlist>

Related

VBA: Value change on a dropdown in IE doesn't update report

I'm automating the download of a report. There is a dropdown for status that needs changing to the value "Started". I've managed to change the value in my code but when you manually make the change the report screen for the site updates automatically. My code doesn't manage to do this.
I'm wondering if there's an extra element that might need changing. Does anyone have any idea what I'm missing?
element on the site:
<select data-bind="value: leads.overall_status, options: [null, 'not_started', 'quoted_with_quotes', 'quoted_without_quotes', 'started', 'open_accounts'], optionsText: BrokerLeadsGridModel.overall_status_renderer" style="width: 160px;vertical-align: baseline;display: inline;" class="form-control">
<option value="">Any</option>
<option value="not_started">Not Started</option>
<option value="quoted_with_quotes">Quoted</option>
<option value="quoted_without_quotes">No Quotes</option>
<option value="started">Started</option>
<option value="open_accounts">Open</option>
</select>
My Code:
Doc.getElementsByClassName("form-control")(0).Value = "started"
Did you try attribute = value css selector?
doc.querySelector("[value=started]").selected = True

How to stop Vue.js from selecting the first option in select option?

My Vue/Buefy app automatically selects the first option from the list:
<b-select model="form.cities[i].index"
v-on:input.once="analyt('City ' + i)"
#input="form.cities[i].name = cities[form.cities[i].index ['#attributes'].Name"
:id="'city-'+i"
:name="'city-'+i"
:required="i == 0"
>
<option
:value="index"
v-for="(city,index) in cities"
v-text="city['#attributes'].Name">
</option>
</b-select>
How do I avoid that? I just want empty field selected by default (or nothing to be selected at all)
Could you just add an empty option field? This should solve your problem.
<b-select model="form.cities[i].index"
v-on:input.once="analyt('City ' + i)"
#input="form.cities[i].name = cities[form.cities[i].index ['#attributes'].Name"
:id="'city-'+i"
:name="'city-'+i"
:required="i == 0"
>
<option selected></option>
<option
:value="index"
v-for="(city,index) in cities"
v-text="city['#attributes'].Name">
</option>
</b-select>
I solved this problem by making sure the first element in the populating array was my default (the one I wanted selected). Then I set the value of the select element to the default.
In my case, I was populating the drop down list based on selection of a different drop down.
First drop down
<select id="firstDropdown" #change="populateDropdown">
// options code ...
</select>
Drop down being populated by the first drop down.
<select id="populatedDropdown">
<option v-for:"item in items">
{{ item }}
</option>
</select>
In Component script
data: function() {
return {
items: []
}
},
method: {
populateDropdown() {
// fetch items from api and store in "array".
this.items = ['Default'].concat(array);
document.querySelector('#popualtedDropdown').value = 0;
}
I hope that makes sense and helps.
<option
value="none" selected disabled hidden>
</option>
This worked for me seamlessly.
Another option is
<option
selected>
</option>
which gives an empty first entry in the list which is a bit undesired.

Get selected option value in change event

I have a dropdown with the following attributes on it:
<select value.bind="row.columns[$parent.$index].colSize" change.delegate="changeColumnSize($parent.$index, $index, row.columns[$parent.$index].colSize)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
But it seems that I cannot pass row.columns[$parent.$index].colSize as an parameter. It is always undefined.
How can I pass the selected value of the dropdown directly to the change events method?
You're missing the value.bind in your select options. I prefer to use mode.bind instead of value.bind though. Try something like this:
<template>
<select value.bind="changedValue" change.delegate="DropdownChanged(changedValue)">
<option model.bind="1">1</option>
<option model.bind="2">2</option>
<option model.bind="3">3</option>
<option model.bind="4">4</option>
</select>
</template>
export class App {
changedValue;
DropdownChanged(changedVal) {
alert(changedVal);
}
}
I'm not sure what you're trying to bind the select to, but basically you want to create a variable that you can bind the selected value too. So, the selected value is going to be set to the variable of changedValue. I like to use model.bind because I can bind true/false values instead of everything being a string.
I've made a running Gist for you to use if needed:
https://gist.run/?id=87f6897928feb504dad638d439caf92f

How to get displayed text from disable dropdown list?

how can i get visible value from disable dropdown list ?
Best Regards,
thank you
You can use selenium.getSelectedValue() or selenium.getSelectedLabel(). Both are described here.
If you have a dropdown list defined as follows:
<select name="dropdown" disabled>
<option value="1">one</option>
<option value="2">two</option>
<option selected value="3">three</option>
<option value="4">four</option>
</select>
Then you can use the following script to assert that the (disabled) selected label is 'three'.
String selectedLabel = selenium.getSelectedValue("name=dropdown");
assertEquals("three", selectedLabel);

How to get option text from a dijit.form.Select?

I have a dijit.form.Select on my page:
<c:set var="qualId" value="${previous.qualification.id}" />
<select id="qualification" name="qualification" dojoType="dijit.form.Select" onchange="checkForPHD()">
<option value="-1" label=" "> </option>
<c:forEach items="${requestScope.qualifications}" var="qualItem">
<c:choose>
<c:when test="${qualId eq qualItem.id}">
<option value="${qualItem.id}" selected = "selected">${qualItem.name}</option>
</c:when>
<c:otherwise>
<option value="${qualItem.id}">${qualItem.name}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
Then some javascript that I'm trying to use to set some text to the TEXT of the option chosen from the select box;
function checkForPHD() {
dojo.byId('clazzPHDMessage').innerHTML = dojo.byId('qualification')
.attr('displayedValue');
}
I'd read that the .attr('displayedValue') was suppose to get the text from the selected option in a dijit.form.Select but it doesn't seem to do much? .attr('value') got that values ok but I need the TEXT?
You should use dijit.byId() to get widget instance. Try to use this code to get selected text:
dijit.byId('qualification').attr('displayedValue')
Seems like what you want is the innerHTML of the currently selected option (<option>THIS TEXT??</option>). I think this should do the trick. Loop over all the select's options with getOptions and find the selected one, then return its innerHTML. I don't know if dijit.form.Select has a selectedIndex property, but that would help too.
function getSelectedText() {
dojo.foreach(dijit.byId("qualification").getOptions(), function(opt, i) {
if (opt.selected) {
return opt.innerHTML;
}
});
}
You should try to get the selected node first, then get the attribute you want, as follows:
dijit.byId("qualification").getSelected().attr('innerHTML');
You can try the below Code Snip
dijit.registry.byId("regionList").value;
<select name="regionList" id="regionList" data-dojo-id="regionList" data-dojo-type="dijit/form/Select">
<option value="" selected="true">Select LoB</option>
<option value="Asia" >Asia</option>
<option value="Africa" >Africa</option>
</select>